Moving to D

Nick Sabalausky a at a.a
Wed Jan 5 09:37:33 PST 2011


"bearophile" <bearophileHUGS at lycos.com> wrote in message 
news:ig1d3l$kts$1 at digitalmars.com...
> Adrian Mercieca:
>
>> How does D square up, performance-wise, to C and C++ ?
>> Has anyone got any benchmark figures?
>
> DMD has an old back-end, it doesn't use SSE (or AVX) registers yet (64 bit 
> version will use 8 or more SSE registers), and sometimes it's slower for 
> integer programs too. I've seen DMD programs slow down if you nest two 
> foreach inside each other. There is a collection of different slow 
> microbenchmarks.
>
> But LDC1 is able to run D1 code that looks like C about equally fast as C 
> or sometimes a bit faster.
>
> DMD2 uses thread local memory on default that in theory slows code down a 
> bit if you use global data, but I have never seen a benchmark that shows 
> this slowdown clearly (an there is __gshared too, but sometimes it seems a 
> placebo).
>
> If you use higher level constructs your program will often go slower.
>
> Often one of the most important things for speed is memory management, D 
> encourages to heap allocate a lot (class instances are usually on the 
> heap), and this is very bad for performance, also because the built-in GC 
> doesn't have an Eden generation managed as a stack. So if you want more 
> performance you must program like in Pascal/Ada, stack-allocating a lot, 
> or using memory pools, etc. It's a lot a matter of self-discipline while 
> you program.
>
>

OTOH, the design of D and Phobos2 strongly encourages fast techniques such 
as array slicing, pre-computation at compile-time, and appropriate use of 
things like caching and lazy evaluation. Many of these things probably can 
be done in C/C++, technically speaking, but D makes them far easier and more 
accessable, and thus more likely to actually get used.

As an example, see how D's built-in array slicing helped Tango's XML lib 
beat the snot out of other language's fast-XML libs: 
http://dotnot.org/blog/archives/2008/03/12/why-is-dtango-so-fast-at-parsing-xml/ - 
and look at the two benchmarks the first paragraph links to.

>> Also, is D more of a Windows oriented language?
>> Do the Linux and OSX versions get as much attention as the Windows one?
>

Linux, Windows and OSX are all strongly supported.

Sometimes OSX might lag *slightly* in one thing or another, but that's only 
because there aren't nearly as many people using D on Mac and giving it a 
good workout. And even at that, it's still only gotten better since Walter 
got his own Mac box to test on.

And Linux is maybe *slightly* ahead of even Windows because, like bearophile 
said, it'll get 64-bit support first, and also because the Linux DMD uses 
the standard Linux object-file format while Windows DMD is still using a 
fairly uncommon object-file format (but that only matters if you want to 
link object files from different compilers, and if you do want to, I think 
there are object file converters out there).

But yea, overall, all of the big 3 OSes get plenty of attention.





More information about the Digitalmars-d mailing list