Rakshasa wrote:
Slamlander wrote:
Templates were a kludge for the Smalltalk programmers that couldn't get multiple inheritance right and is a work around for the incest problem (which a proper design shouldn't have anyway). My code does it right and
doesn't need Templates. Think; Booch and forests of virtual base classes.
I take issues with your insinuation that I'm a master of incest.
First, virtual functions can never be as fast as inline or direct function calls. Templates allow the compiler to optimize, sometimes so aggressively you only end up with constants, any weird stuff you might want to do. And they often work on any types matching certain criteria.
Contrast this to virtual base classes where even constants related to the instance must be retrieved through virtual calls, and the type system is much less flexible.
Also, templates are so much more than the standard containers... Look at the STL algorithms for real beauty.
It's nice that your code is perfect, just don't try to live in an imperfect world.
I'll only make one point to this and then agree. Even virtual base classes are faster than Java, which is strictly interpretive (setting aside gjc for the moment).
My point is that Templates can be as abused as macros, maybe more than.
My code is only that way because I was using C++ way long before there were Templates (which Stroustrup only grudgingly added, BTW) and actualy understood virtual base classes in gruesome detail. Yes, there are issues there, usually due to compiler implementation structures and yes, an optimizing compiler only partially counters those issues.
Yes, I do live with Templates. I just don't use them any more than I have to and if it's still faster than equivalent Java code then multiply nested virtual base classes are still better than templates.
But now I'm being a real purist and I detest that. I won't knock anyone for using templates and they are a legitimate part of the language. Holding forth against them makes the purist as snobbish as the Java-Heads are. We are only talking personal style choices here.