On 5/11/2012 12:40 PM, H. S. Teoh wrote:
Yeah, one of the biggest problems with C++ template syntax is that it
looks like an alien language. I remember going, "wait, you have to type
*that* to achieve what can written as a simple loop in normal C++
code?!"
I couldn't tell you how delighted I was when I saw D's much cleaner and
clearer template syntax. I mean, it looks just like normal, non-template
code! Gee, what a concept!
Back when Andrei was writing TDPL, I suggested that he avoid using the word
'template' completely - to simply include type parameters as if they were
completely natural. I think this was a very successful approach.
I got the idea after listening to a friend of mine who taught remedial algebra
to college students. She said that peoples' brains freeze up when they see "x"
in an equation. If she wrote:
x + 3 = 5
on the board and asked people to "solve for x", they would fail completely. But,
if she wrote:
( ) + 3 = 5
and asked them to "fill in the circle with the number that makes it work", they
all went "of course, it's 2!"
C++ has produced a "gee, templates are hard" mentality, and consequently many
people just shut down when they see the word "template".