[Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation

Yitzchak Gale gale at sefer.org
Tue Jul 1 12:18:17 UTC 2014


Hi Kashyap,

I'm responding only now because I just saw this thread on reddit.

You wrote:
> it is clear that String for IO is a bad idea -
> I wonder if examples of String based readFile
> etc for beginners is a good idea

It's not always a bad idea. Especially for beginners.
Conceptually, String is the simplest, and often the performance
isn't so bad. For serious applications, though, you should use the
text library.

One thing you should never use for text is ByteString - that is
for binary data, not text.

Lazy IO is also OK in simple cases. But as you have seen,
for real applications you need to be aware of its limitations.
When there is interleaving of IO operations between multiple
resources, the simplicity of lazy IO disappears very quickly.
In those cases, you should consider alternative IO libraries,
such as conduit and pipes.

Regards,
Yitz


More information about the Haskell-Cafe mailing list