I think they do it mainly just to get me.

The problem with templates, as Igor touches on, is that they are a very sharp 
knife. In the hands of a skilled coder they can do wonderful things, but it's 
something that can easily get out of hand. Templates are Turing complete so you 
can create very expensive compilations.

Properly used templates let you avoid a lot of type casting, which is _always_ 
risky (although in some cases unions are a better choice). It can also cut down 
on cut and paste which is more of a maintenance problem than templates. In some 
ways it's like event oriented programming, where you end up doing things 
indirectly rather than straight up, with similar costs and benefits.

Fundamentally, IMHO, the point of templates is to introduce Lisp programming 
techniques in to C++. Whether that's a good thing is a matter of opinion.

I have somewhat of a biased view as I was doing template style programming 
before C++ had templates (using the Common Lisp Object System) so it's second 
nature for me.

P.S. I've definitely found more than one bug in a compiler (both MSVC and g++) 
from templates. I used to think that if I wasn't crashing the compiler with my 
templates, I wasn't really trying. That's become a bit harder but I expect I 
can get back to it when C++0xeleventy1! is generally available.

Saturday, December 3, 2011, 8:15:58 AM, you wrote:

>> Not that I'm for or against templates, but would
>> love to hear what are the technological reasons for
>> their exclusion/opposition/whatever.


Reply via email to