templates : damn them to hell

Started by
64 comments, last by squirrel_of_death 19 years, 10 months ago
Since when were templates tacked on to C++? If I recall correctly from D&E, templates were added as a better form of C macros and not exactly an afterthought. I don''t particularly understand the meaning of "tacked on to C++" in this context given that most of C++ is stuff tacked on to C.

Microsoft has properly supported templates for their original use for years (I recall them being in a version prior to 6). Many of the fancier extensions to the original template design were added late in the standardization process in order to support research into some of the more peculiar uses that were being discovered at the time.

Templates do a great job of accomplishing the goal they were originally intended to accomplish. Arguments that other languages support better forms of such and such completely miss the point.
Advertisement
Alrighty then

Templates are about soliving problems of algorithmic generality in strongly typed languages that compile to machine code. Strongly typed languages themselves stem from the stone age where a pointer to something could be mis-applied and corrupt memory in some way. Ladies, we are *way* past that point.

Templates are wonderful in theory, but really they''re little more than what some have called "macros on steriods". The extreme difficulty of desinging rational compilers (most based on legacy C++ compilers) to handle all the legal constructs that follow from the template syntax results in a patchwork of heuristic rules about what a particular template declaration actually compiles to. What we''ve done to C++ with templates is create two languages: the C++ "base" language, and the "meta-language" of template programming. If you don''t agree, just ask any architect from you favourite compiler vender.

The reference to Smalltalk from someone on this thread is apt: an object is an object. If an operation on it is illegal, then it''s a program error. You can fix those, because you know what you intended to do. It''s a heck of a lot easier to straighten out a program to do what you wanted it to do in say, Java, than fight with the arcana of syntax and guessing what the compiler translated your program prose into.

I love C++. Really. But it''s come to the end of its useful life for most responsible software engineering applications. Let it die a noble death.
quote:Original post by Anonymous Poster
Templates and multiple-inheritance is just stupid hacks to get around limitations, for example linked-list creation.
The java-solution with an Object-class is much nicer.

/Fredrik


Its so mucher nicer that sun have completed reimplementated there whole collections library as paramterized types. I''ve beening looking into java generic and i have to say it is impressive, there isn''t any multiple instantiations only one .class compiled, you can also specifiy that only a certain range of types can be passed to its parameter which you can''t normally do with templates, the downside is you can only pass user defined types and not primitive types but then you have autoboxing for that.

Generics (in any language) give us the ability to not only have dynamic but also static polymorphism. People tend to overuse dynamic polymorphism when it isn''t really needed or in the wrong place and static polymorphism is great for this.
necro-rised

}-- Programmer/Gamer/Dreamer --{
I didn''t choose to code, coding choose me.
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]
why are necros often done by anonymous posters? kind of seeing a pattern here.
Number of posts talking about necro >= number of on topic posts -> Closed.

This topic is closed to new replies.

Advertisement