More Interesting Language than Haskell?

Is Haskell worth learning? Is it interesting to study?

If you would have to learn Haskell for an actual project with a time constraint, pick something like Python or Scheme instead, where the transition is a lot less of a burden and the chances for success are higher (Assuming you are a C/C++/Java/Perl programmer). If you are doing a report about the language, then I wouldn’t hesitate to say that Haskell is very interesting to study and I think you will really enjoy even just reading about it (and hopefully tinkering with it)! [1]

Try Haskell Today, for Free!

Before saying anything about the language, I will let you go look at it. See if you can figure out what each little piece does.

Example code

-- obligatory factorial function
fac n = product [1..n]

-- fibonacci numbers calculated in O(n) time
fib n = fibs !! n
fibs  = 1 : 1 : (add fibs (tail fibs))
add   = zipWith (+)
-- infinite factorial stream (also O(n))
nums  = [1..]
facs  = 1 : (mul nums facs)
mul   = zipWith (*)

Interactive session

Main> map fac [0..10]
[1,1,2,6,24,120,720,5040,40320,362880,3628800]
Main> map fib [0..10]
[1,1,2,3,5,8,13,21,34,55,89]
Main> take 11 fibs
[1,1,2,3,5,8,13,21,34,55,89]

Tutorials and introductions in order of importance:

You can get it online and play with it or read more about it.

  1. Haskell.org for everything Haskell related, including free, open source compilers/interpreters (there are no “better” commercial-only version that I’m aware of; this is similar to the state of Python and Perl, but distinct from Lisp, Java or C/C++)
  2. Yet Another Haskell Tutorial (now, the Haskell wikibook!): This tutorial seems to be structured in a way that I would gladly wish upon anyone. It also has good links to other places, installation guides, explains pitfalls carefully, but is under construction. Read this and you quickly get a feel for Haskell.
  3. A “Gentle” Introduction to Haskell: The standard tutorial: it is more succint than YAHT but is almost somewhat terse and unforgiving, though well done and well written. I like it but consider reading YAHT first.
  4. The online report is a good official reference of the language. (Or check out the defintion of Haskell 98 for printable versions—I’m crazy enough I printed and bound this thing—277 pgs—and read it all the way through for fun, but that’s just me)
  5. Maybe you can find this book at the library: The Haskell School of Expression. It is an introductory text but uses interesting examples from graphics to cover some advanced topics.

 

 

 

Notes

[1] I remember before I spent the time to learn it or really write programs in it, I read some tutorials and was surprised at how interesting and consistent and clean and understandable it seemed. Of course this is different than actually learning to speak the language, but I definitely admired it before I got a chance to use it.