[Haskell-cafe] Can Haskell outperform C++?
roma at ro-che.info
Sun May 6 11:23:06 CEST 2012
* Artur <apeka1990 at gmail.com> [2012-05-06 11:41:58+0300]
> isn't it that particular Haskell code is outperforming C (22 seconds
> vs. 33), just because the author uses recursion in C? I surely love
> Haskell, and the way it's code is easy parallelized, but that example
> seams not fair.
I think the point was to take two programs of similar code complexity
(or, rather, simplicity) implementing the same algorithm (modulo
So I'm not sure what exactly you're objecting to.
If you're saying that there are better algorithms to compute Fibonacci
numbers, it's not relevant — the important thing that the two
programs are computing the same thing in the same way.
If you're saying that in C an explicit stack should have been used
instead of recursion, then it would increase the code complexity while
having non-obvious performance benefits.
In any case, assuming that on this particular task Haskell is x times
slower than C, taking sufficiently many cores and large enough N would
The again, I don't think that article was meant as a fair comparison
between Haskell and C on an average task. (The chosen example consists of
one loop which is easily parallelisable.) All it demonstrates is that
it is very easy to exploit parallelism in Haskell when there's an
Roman I. Cheplyaka :: http://ro-che.info/
More information about the Haskell-Cafe