MHD wrote:D does templated metaprogramming about twice as well as C++.
(...)
Jplus wrote:(...)
Anyway, I'll have a look into your claim that D has stronger generics than C++.
Alright, I had a look at D, and this is my first impression. "Templates" in D seem to be a different beast from templates in C++. In D, they serve as the solution to two problems at the same time: static metaprogramming and type generics. In C++ on the other hand, templates mostly serve as a way to achieve type generics while static metaprogramming is mostly done using the C preprocessor language. I say "mostly", because there is such a thing as "template metaprogramming" in C++, which Alexander Stepanov prefers to call "ugly hacks".
The D approach to
template metaprogramming looks arguably more elegant than the C++ approach, so in that sense MHD was right. However, one could argue that you shouldn't use the same syntactic element of a language for two different purposes. It would be most elegant and most powerful to have static introspective type functions, as a superior alternative to template metaprogramming. Since neither C++ nor D comes close to this ideal solution, both are in a sense ugly. Besides, D doesn't seem any more powerful than C++ in its capabilities to replace type functions.
I'm not sure whether it was MHD's intention to also claim that D has stronger
generics than C++. Either way, I haven't seen a reason yet to think such a claim would be valid. At this point it's rather unclear to me what are the differences between C++' and D's generic capabilities, and I'm wondering whether I could for example write a class template in D -- or what would be the equivalent of such a thing. It seems that templates in D can be used to generate a function, a constant or something else, depending on other factors.
Overall, types and operations seem to be better separated (more orthogonal) in C++ and Haskell than in D, but I might be wrong.