[Haskell-cafe] Can Haskell outperform C++?

Isaac Gouy igouy2 at yahoo.com
Fri May 18 19:51:44 CEST 2012

----- Original Message -----
> From: "ok at cs.otago.ac.nz" <ok at cs.otago.ac.nz>
> Sent: Friday, May 18, 2012 9:38 AM
> Subject: Re: [Haskell-cafe] Can Haskell outperform C++?

>>  and if we want
>>  to compare *languages*, we should use identical algorithms to make the
>>  comparison fair.
> In the permutation generation example, I was talking about
> four programs:
>            Language X  Language Y
> Method 1   Program X1  Program Y1   -- identical algorithms
> Method 2   Program X2  Program Y2   -- identical algorithms
> However, "identical" isn't clearly defined.

Moreover, being absolutely sure that the algorithms are in some sense 
"identical" might make comparison pointless - for example, when the same assembly 
is generated by gcc from a C program and gnat from an Ada program.

> In the 'tsort' case, it turns out that the Java and Smalltalk
> versions are I/O bound with over 90% of the time spent just
> reading the data. 

My guess is that they could be written to do better than that - but it's 
idiotic of me to say so without understanding the specifics, please 
forgive me ;-)

> They have I/O libraries with very different
> structures, so what does "identical algorithms" mean?  If you
> are using dictionaries/hashmaps, and the two languages have
> implementations that compute different hash functions for strings,
> is _that_ using the same implementation? 

Of course, to some degree, user defined hash functions remedy that specific problem.

I agree with the thrust of your comments - even programming languages (and implementations) that seem similar, are often so different (when we get down to specifics) that comparison between programs written in different languages is a matter of making the best of a bad job.

But we're still going to ask - Will my program be faster if I write it in language X? - and we're 
still going to wish for a simpler answer than - It depends how you write it!

More information about the Haskell-Cafe mailing list