Unclear about the benefits of D over C++ and Java

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 2 03:40:35 PST 2016


On 03/01/16 12:31 AM, Dibyendu Majumdar wrote:
> Hi,
>
> I am a long time observer of D but have never done any coding in D. I
> have considered using D several times but have ended up either going
> with C++ or Java.
>
> I feel that for someone like me it is not clear what significant
> advantages D has over C++ or Java to make a switch. I cannot afford to
> experiment with a language unless I know for certain the benefits of
> using it.
>
> For instance I would like to know:
>
> * Do D compilers generate more efficient code compared to C++ compilers?
> Are there performance benchmarks comparing D implementation against C
> and C++?
>
> * Can D generics do everything C++ templates can (are they Turing
> complete for instance) - and what additional capabilities does D have
> that would make a significant difference to the way templates are used
> in C++?
>
> * How does D's performance compare with Java when it comes to concurrent
> applications or garbage collection?
>
> * How stable is D? Can one use it without fear that the next version
> will significantly change the language and therefore one would have to
> rewrite?
>
> I feel that the D website could do more to explain why someone should
> move from C++ or Java to D - and this has to be explained in terms of
> real world benefits in terms of:
>
> * Performance
> * Quality of implementation
>
> For someone like me - cool language features don't count that much
> unless they lead to real world benefits.
>
> My post here was triggered after watching a video by Andrei where he
> talked about how D generics are different from C++ templates - I think
> stuff like that needs to be explained in the front page of D website.
>
> Regards
> Dibyendu
>
> http://ravilang.org
> http://simpledbm.org

Okay so lets start with code efficiency.
We can beat in some cases and match C++ code generation using gdc or 
ldc. Which use GCC and LLVM backends.

About D templates. Anything can be executed at compile time can be used 
in templates. You just can't interact with non D code or globals.
Same with e.g. static assert.
Because of this D's meta-programming capabilities beat almost all other 
languages (Lisp in general is the only set of language that we don't).

Okay, now about general performance and the GC.
If you want performant apps you can't use the GC. It's as simple as that.
The Java and .net crowd like to say otherwise but you just can't. No GC 
will work as well for memory management quite as like a developer can.

In terms of language changes, you shouldn't need to worry about it too 
much. Most of the time these days you can go between versions without 
any changes if you're not pushing the language too much.
It's not like what it was a few years ago.


More information about the Digitalmars-d mailing list