D and Nim

logicchains via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 5 03:44:32 PST 2015


On Monday, 5 January 2015 at 00:01:34 UTC, Walter Bright wrote:
> D:
>     printf("%d LANGUAGE D %d\n", len, sw.peek().msecs);
>
> Correctly written D:
>
>     writeln(len, " LANGUAGE D ", sw.peek().msecs);

Just a note that the reason it uses printf is because, when ldc 
was working on ARM, writeln produced gibberish characters.

On Sunday, 4 January 2015 at 21:46:09 UTC, Ary Borenszweig wrote:
>There was a time I liked D. But now to make the code fast you
> have to annotate things with pure nothrow @safe to make sure 
> the compiler generates fast code. This leads to code that's 
> uglier and harder to understand.

For this particular benchmark I noticed little effect on the 
speed of the program from these annotations, I just originally 
added them for that warm fuzzy feeling that comes from marking 
things immutable/pure.

Also, in relation to comments about -boundscheck=off (aka 
noboundscheck), it's interesting to check out the latest Rust 
version. Previously, it was a bit slower than C++, D and Nimrod. 
Now, it matches them... by converting the code to use a tree in 
order to avoid bounds checks! 
https://github.com/logicchains/LPATHBench/blob/master/rs.rs. 
Personally I prefer D's approach.


More information about the Digitalmars-d mailing list