D and Nim

Joseph Rushton Wakeling via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 4 16:26:47 PST 2015


On 04/01/15 22:46, Ary Borenszweig via Digitalmars-d wrote:
> According to the writeup:
>
> https://github.com/logicchains/LPATHBench/blob/master/writeup.md
>
> Nim is faster than D. And it does so with much less code.

Meh, if you compare the code in detail you realize (i) the D example "wastes" a 
lot of lines with imports, { } brackets, and a second implementation of the core 
algorithm using std.range/std.algorithm functionality instead of the "naive" 
(but it seems, faster) implementation.

The rest of the weight in lines is down to a not-so-nice "readPlaces" method 
that could be rewritten idiomatically in D in much less space, but no one's 
bothered because it's not actually part of the benchmark.

Now, to the numbers -- the x86-64 benchmark shows a 50ms difference between Nim 
and D.  That's such a trivial difference, it's difficult to know what is 
responsible; depending on whether the results are averaged over multiple runs, 
it might even just be random fluctuation, or differences in the implementation 
of the time measurement.  Looking at the runbench.sh code, I don't think there 
is any averageing, so it's not a very certain measure of what is best.

The results from the Haswell processor seem more clear-cut, but without more 
information, I'd hazard a guess that there the person concerned tweaked the 
build file to use dmd, rather than the superior (for code speed) ldc2 or gdc.


More information about the Digitalmars-d mailing list