[Haskell-cafe] Why Haskell is beautiful to the novice

Silvio Frischknecht silvio.frischi at gmail.com
Sat Aug 29 15:19:51 UTC 2015

> Haskell is great for teaching kids logic, math, data structures - you
> just can't skip details the way you can with experienced programmers.
> This isn't that much different from teaching adults who aren't
> experienced programmers.

Most people on this list (me included) are probably people enjoying math
and logic. But I know a lot of people who love CS and even do it
professionally who think of math as a bit of a chore. Most of those take
one look at Haskell and say "I'm not interested". With Python or
Javascript/HTML you will be able to motivate a much bigger part of your
audience. HTML was one of the first things I learned in CS.

Also just wanted to add an example of how Haskell can be really tricky
for very simple things.

Let's consider the simplest loop I can think of. The function to sum up
all the numbers up to N. Anyone new to Haskell will implement this in
the straight forward way.

sumToN 0 = 0
sumToN n = sumToN (n-1) + n

It's very elegant. It's more of a definition than an algorithm, really.
The equivalent python code would probably do a loop (4-5 lines).

Now, if you run your python code for a billion, it will eventually
return the correct result because you specified the algorithm more
clearly. If you run the Haskell function for a billion however, it will
crash your computer and set your house on fire.

Now, you will have to explain tail recursion and why you won't get a
StackOverflow despite the fact that you build up a huge stack. I have
done Haskell for a quite a while, and I'm still unsure sometimes if
something will work in constant space or not.



More information about the Haskell-Cafe mailing list