[fpc-devel] Generics Basics
Daniël Mantione
daniel.mantione at freepascal.org
Wed Nov 9 12:53:01 CET 2005
Op Wed, 9 Nov 2005, schreef Bram Kuijvenhoven:
> Daniël Mantione wrote:
> (Ok, maybe I'm exaggerating a little bit, but don't you agree generics /are/
> useful?)
Certainly I do agree. However, they *will* be used to introduce the
bloated programming I described. I don't think we should be happy with
that.
> Won't the compiler sometimes be able to handle this smarter? When the code
> generated for vector<TClassA> and vector<TClassB> is equivalent, we only need
> to include it once in the resulting executable, right? The only thing is we
> have to see when this situation occurs.
These tricks have been used in some C++ compilers with very limited
success. The problem is that class_a has a different virtual
methods/constructors/destructors than class b, so the code to be generated
for them will be different, even though they are still just basically
arrays of pointers.
> But if I am correct, this is in general not the case for container classes
> like vector<T> (or: TList<T>).
Check code generated by the C++ compiler. I did it a lot last year to
reduce my binaries. Reducing the code size meant removing usage of the
STL, as all vectors etc. appeared in the object code in tenfolds.
> > Templates can save typing. People are demanding them, because there is a
> > hype. Lack of templates is seen as a deficiency of Pascal against C++.
>
> Somehow people from the well known ACM programming contest seem to see Pascal
> as a 'deficiency' itself:
>
> >From "The Rules of the 2005 ICPC Regional Contests"
> (http://icpc.baylor.edu/icpc/regionals/About.htm):
>
> "The programming languages of the regional contest will include C/C++.
> Additional programming languages may be used. The programming languages of the
> 2006 World Finals are Java, C/C++, and Pascal. Prior to the World Finals, the
> judges will have solved all problems in Java and C/C++, but not necessarily in
> Pascal. Pascal is a legacy language that is provided at the World Finals as a
> courtesy to the teams that are still dependent on it. Pascal will no longer be
> available starting with the 2007 World Finals."
>
> I think that indeed C++'s STL and Java 1.5 rule over Pascal at the moment for
> programming contests. Perhaps generics & a nice container library using
> generics can help getting Pascal back (but I don't know all the considerations
> of the ACM World Finals' organisers!)
No. Pascal is not a deficient language in any way; it has way more usefull
features than C++ has. What will save it is good, very good development
tools and good, very good libraries.
If you think templates will save Pascal, or it will die without, that is a
very naive thought. The most used language is stil standard C. Why?
Daniël
More information about the fpc-devel
mailing list