D vs C++

Walter Bright newshound2 at digitalmars.com
Mon Dec 27 12:54:42 PST 2010


bearophile wrote:
>> Templates are far more than just generics.
> 
> But an army of people argue that using templates for more than generics is
> bad.

Not surprising considering how awful templates are in C++. Don't make the 
mistake of transferring that to D, which does things significantly differently.


> In C++ you use templates for generic data structures and classes, for
> metaprogramming, for type-level computing, and probably for other things. For
> metaprogramming even D doesn't use templates much any more (after the
> introduction of CTFE), most other ways to perform metaprogramming are better
> than doing it with C++ templates. Type level computing is better done with
> staged compilation, a type to represent a type, more flexible type sytems,
> etc. See modern functional languages.

Nobody here is arguing that C++ nailed it with templates.


>> That happens at compile time. That happens at run time. D's happens at
>> compile time.
> 
> Python has a wonderful advantage over D: there is no compilation! You write
> your code and you run it!

The compilation being hidden from you doesn't mean it isn't happening.


> So no need to let things happen at compile-time. If
> you want to pre-compute things you can just split your program in two levels
> and run a level before another, or use eval/exec. So Python is better here. 
> No compilation, no problems :-) Generative programming in Python is way
> better than D :-)

There is no "pre-computing" things in python. It's all redone from scratch every 
time you run a python program.


> Generally I don't post a message in a sub-thread like this. In the end what's
> the purpose of this sub thread? Is Python better than D? Who cares?

You started off this thread claiming that D had almost no advantages over Python.


More information about the Digitalmars-d mailing list