D - more or less power than C++?

Andrew Fedoniouk news at terrainformatica.com
Fri Mar 3 15:37:32 PST 2006


>> 7. D has all (well, most of) the power of C++
>
> I see this often and am a bit perplexed by it. What power do you feel is 
> missing?
>
> And what about the missing power in C++ - inline assembler, nested 
> functions, contract programming, unit testing, automatic documentation 
> generation, static if, delegates, dynamic closures, inner classes, 
> modules, garbage collection, scope guard?
>
> What does D have to do to have more power than C++?

1) C++ has ctors/dtors for stack allocated objects. This problem
is known in D as luck of struct ctor/dtor.

2) C++/C both have const.

These two are corner stones in C++ (among others).
The whole std:: namespace without them is just impossible.

I cannot imagine serious *library* design without 'const' for example.
Library here means design of robust code used by millions.
Phobos imho will never be considered as something rock-solid without
'const'.

You can add as many features (really nice ones, btw) on top of
C syntax but these two are so principal and widely used
that without them C++ crowd will not even think about D.
Tons of existing code around them.

For me personally D is definitely more suitable than C++ for e.g.
UI programming in many areas. But not in all.

E.g. I have tried three or four different approaches
to reproduce string value type in D. Just no way.
Everything what I've seen so far is non-comparable
with even std:string and I am yet silent about .NET and Java.

Big picture: templates (at some extent) and
definitely delegates are superior in D than in C++.
Other features are more or less elegantly reproducible in C++.

D used to have clean,consistent and simple syntax and execution model
(e.g. GC "from the shelf") but holes 1) and 2) on the bottom of this ship
are just shining.

IMHO.

Andrew.
http://terrainformatica.com








More information about the Digitalmars-d mailing list