A while back there was a story here at classy.dk about how Developers are more important than development environment, based on an informal study of different programmers doing solutions in different languages of the same problem.
I found another programmer who took the bait. This time it's a C++ programmer inspired by Peter Norvigs Lisp arrogance. He manages to demonstrate that the developers of the templating system had a bad case of abstraction envy when they designed the template mechanism, and is able to basically copy the Lisp version into templated C++.
The template mechanism is wonderful except for two facts:
First, the C++ compiler - under heavy use of templates - is basically the slowest runtime environment for ideas I can think of. Clearly a new approach to the use of clock cycles is needed to make the C++ compile cycle acceptable. I'm sure any heavy user of templates can understand that sentiment, even if he doesn't agree.
I think basically what is needed is to stop thinking about the compile cycle as an offline activity - which is inherent in C/C++ think with the use of preprocessing, makefiles etc. Things like 'precompiled headers' are just hacks to work around the underlying issue that the model for how C and C++ generates code needs an overhaul.
The second fact is the more serious: Templates violate the fundamental principles of good productivity enhancers. Debugging template rich code is terrible, since the names of things that you use as short hand to make your code legible have vanished in the debugger, i.e. you cannot debug in your thought medium. In fact it can be hard enough to create even facades for your template rich libraries that let you wtop worrying about the templates themselves. STL and some of the 'gold-standard' libraries around make a very good effort in this respect but it is punishingly difficult for the average programmer. And it is not made easier by the poor interactive qualities of the template processor. (Basically you want to single step compilation - which is what I mean when I say the C++ compiler is really a runtime environment)
Generics are poised to enter both C# and Java. For J2EE programmes the obscurity of templating techniques should provide a welcome pause to the arcane work they have to do to write millions of classes (not to mention deployment descriptors) to provide J2EE services, but one would hope that the Java and C# language designers come up with a better way to open up the template processor for debugging etc., while hiding the results of running it from client programmers.
Posted by Claus at December 16, 2002 10:34 PM