
On 23 Dec 2005 22:29:02 +0100, Peter Simons
Daniel Carrera writes:
when I have a simple algorithm and performance is an issue [...] I'd use C.
You don't have to. You can write very fast programs in Haskell.
I never really finished the article I wanted to write about this subject, but the fragment I have might be interesting or even useful nonetheless:
http://cryp.to/blockio/fast-io.html http://cryp.to/blockio/fast-io.lhs
One of the interesting points that this illustrates (to me) is that the "obvious" approach in Haskell can be seriously non-optimal in terms of performance. Add to this the fact that tuning functional programs is a non-trivial art, and it becomes quite easy to see why Haskell might come across as slow. Your wcLazy implementation is (as you say) the "obvious" approach. Your two other approaches aren't particularly obvious, althought they are far more efficient. It would be interesting to see standalone code for wcIOB (where you're allowed to assume that any helpers you need, like your block IO library, are available from the standard library). This would help in comparing the "obviousness" of the two approaches. Paul