Analysis of programming languages on Rosetta

Joakim via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 24 15:22:49 PDT 2014


On Wednesday, 24 September 2014 at 21:54:12 UTC, bearophile wrote:
> Joakim:
>
>> So Haskell programmers don't care about fast programs and 
>> don't know how to choose good algorithms? ;)
>
> Haskell programmers that write the Rosettacode entries usually 
> care for code succinctness and code simplicity more than they 
> care for performance (and I think they are often right). Often 
> the best algorithms requires longer programs.
>
> You can see it very well here:
> http://rosettacode.org/wiki/Iterated_digits_squaring

Ouch, your worst idiomatic yet simple D version took 10 seconds, 
whereas the Haskell version took "less than eight minutes."  Of 
course, that's meaningless if they were run on CPUs that varied a 
lot in ability, but am I right in guessing that you wrote the 
Haskell version too?

If so, I do think it means something that the simple version for 
D was so much faster, but depending on the possibly easy 
optimizations missed by the Haskell implementor, maybe not much.

>> I understand that Rosettacode is not geared towards 
>> performance, but that's why it makes a good sample for the 
>> authors of idiomatic code in each language,
>
> Look at the four D entries I have written for that 
> Iterated_digits_squaring task. I think all the first three 
> entries are idiomatic, but their run-time varies wildly. Saying 
> "idiomatic code" is not enough. You can write a very idiomatic 
> Haskell entry that's much faster than the basic currently 
> present.

Yes, the skill of the contributors and amount of time spent 
matters a lot, no doubt.  I will note that none of the D runtimes 
goes up to 8 mins, even the translated Haskell version, but maybe 
you're just that much better than that volunteer. ;)

>> Good to see you put so much time into publicizing D,
>
> The Rosetta code site is far more important/interesting than 
> just publicizing languages. And I have written entries in 
> several other languages too.

Yeah, it's great for all coders to explore different ways of 
implementing the same concepts and see lots of sample code 
generally.  Too bad most aren't that interested in the former, 
but that's understandably a small group.

>> but I wonder how well-known that site is,
>
> It's sufficiently known, but perhaps only for certain 
> programmers. The ones that care about the design of programming 
> languages are more likely to know it.

Yeah, that doesn't include me.


More information about the Digitalmars-d mailing list