[Haskell-cafe] Amazing

Jeremy Shaw jeremy at n-heptane.com
Sun Feb 15 01:20:14 EST 2009


At Sun, 15 Feb 2009 05:37:12 +0000,
Sebastian Sylvan wrote:

> So my conclusion is that it's not just static typing, it's functional
> programming in conjunction with static strong type checking.

Indeed. For example, it's pretty hard to accidentally use an
'uninitialized variable' in Haskell, because variables can only be
introduced using the let statement or a lambda expression, which both
require that the name be bound to something.

And, in languages like C if you write:

----------------------

if (foo)
    statement1;
else
    statement2;
    statement3;

statement4;

----------------------

You might be mislead into think that statement2 is part of the
conditional. In Haskell, if you write:

do if foo
    then do statement1
    else do statement2
            statement3
   statement4

then the visual layout gives you the correct idea.

I think the lack of automatic type casting and C++ style name
overloading also helps. If you explicitly state what you want done,
you are more likely to get what you want than if you let the compiler
do it according to some rules that you may or may not remember.

I have had the unfortunate experience of adding 1 + 1 and getting 11
in some languages. But, not in Haskell.

By using folds and maps, we avoid many off-by-one errors.

So, I would agree that it is not just static type checking, but a
whole bunch of little things that all add up.

- jeremy



More information about the Haskell-Cafe mailing list