[Haskell-cafe] Re: One question...

Benjamin Franksen benjamin.franksen at bessy.de
Sun Dec 10 16:23:42 EST 2006


Waldemar Biernacki wrote:
> I have to admit that I think that as shorter source code as better.
> Therefore the question to those who know Perl: is the source code of a
> client-server application shorter in Haskel to compare to Perl one?
> How much shorter (more or less)?

My only hard data point here is this: I once converted (just for fun) a
short (two screenful) Perl script to Haskell and found that both are about
the same length (in LOC). (I find the Haskell version is more readable, but
that may just be a personal preference; Perl's syntax is a bit too noisy
for my taste.)

Anyway, don't let yourself be misled by small trivial examples. For some
idioms (e.g. line oriented I/O) Perl has special syntactic sugar that leads
to very short code. This makes it quite useful for one-liners that you can
hack directly into the command line. However, as programs get larger and
more complex, other factors dominate the equation. I'd say the most
important aspect is how easy it is to factor common code into
functions/subroutines. I think it is very hard to beat Haskell here because
of it's excellent support for higher order functions. Yes, you can do
higher order functions in Perl (I often do it, my Perl programming is
heavily influenced by Haskell ;) but without a type system it can become
quite a challenge.

Cheers
Ben



More information about the Haskell-Cafe mailing list