[Haskell-cafe] Amazing

Michael D. Adams mdmkolbe at gmail.com
Sun Feb 15 02:34:34 EST 2009

2009/2/15 Sebastian Sylvan <sylvan at student.chalmers.se>:
> 2009/2/14 Peter Verswyvelen <bugfact at gmail.com>
>> One of the things I liked a lot when working with C# was that as soon as
>> my code compiled, it usually worked after an iteration of two.At least if we
>> forget about the nasty imperative debugging that is needed after a while
>> because of unanticipated and unchecked runtime side effects.
>> After heaving read about Haskell and having written some small programs
>> for the last year or so, I'm now finally writing a bigger program with it.
>> It is not so easy yet since learning a language and trying to reach a
>> deadline at the same time is hard :)
>> However, it is just amazing that whenever my Haskell program compiles
>> (which to be fair can take a while for an average Haskeller like me ;-), it
>> just... works! I have heard rumors that this was the case, but I can really
>> confirm it.
>> A bit hurray for strong typing! (and if you don't like it, you can still
>> use Dynamic and Typeable ;-)
> I've found the same thing. An interesting observation is that (for me) the
> vast majority of the type errors are things that would've happened in *any*
> statically typed language (like C#), but somehow Haskell manages to be a lot
> better at catching errors at compile time.
> So my conclusion is that it's not just static typing, it's functional
> programming in conjunction with static strong type checking.
> When all you're writing are expressions, then *everything* goes through some
> level of "sanity checking". When you're writing imperative code, a lot of
> the meaning of your program comes from the ordering of statements - which
> usually isn't checked at all (aside from scope).
> So IMO static typing is good, but it's only with functional programming that
> it really shines.

Don't forget Algebraic Data Types.  Those seem to also avoid many of
the sorts of errors that you would see in OO or struct-based (i.e. C)

Has anyone seen any real studies of this phenomenon?  There is plenty
of anecdotal evidence that Haskell is doing something right to reduce
the bugs, but (1) some hard evidence would be nice and (2) its not
very clear which features of Haskell most contribute to this.  (On
that note, IIRC there was a study that correlated bug rates to lines
of code *independent* of language (i.e. writing your program in half a
many lines or a language that allowed you to express it in half as
many lines reduced the number of bugs by half).  This is one area that
Haskell does well in.)

Michael D. Adams
mdmkolbe at gmail.com

More information about the Haskell-Cafe mailing list