Inherent code performance advantages of D over C?

Maxim Fomin maxim at maxim-fomin.ru
Fri Dec 6 15:02:27 PST 2013


On Friday, 6 December 2013 at 22:20:19 UTC, Walter Bright wrote:
>
> "there is no way proper C code can be slower than those 
> languages."
>
>   -- 
> http://www.reddit.com/r/programming/comments/1s5ze3/benchmarking_d_vs_go_vs_erlang_vs_c_for_mqtt/cduwwoy
>
> comes up now and then. I think it's incorrect, D has many 
> inherent advantages in generating code over C:

What surprises me most is claim that D can 'hypothetically' 
generate more efficient code comparing with C, especially taking 
into account current situation with code generation and 
optimization.

The claim about inherent advantages implies that code generation 
is not good now. If it can be so efficient, why it is not the 
case? And if in practice it is worse, than who cares that 'in 
theory' code can be better?

I believe that most of your points are either insignificant (like 
array length - it is carried together with pointer almost 
everywhere in C) or provide some marginal advantage. Such 
advantages are offset by:

- huge runtime library
- constant runtime lib invocation and allocation stuff on heap
- horrible mangling (see 
http://forum.dlang.org/thread/mailman.207.1369611513.13711.digitalmars-d@puremagic.com 
examples from hall of D mangling, mangling is so big, that forum 
software goes astray)
- phobos snowball - one invocation of some function in standard 
library leads to dozens template instantiations and invocations 
of pretty much stuff


More information about the Digitalmars-d mailing list