I like to hang around on a French-speaking, programming IRC channel. I’m known there as “the language guy” because of my hobby of trying all sorts of different and weird languages. I’m also known as being the guy that touts the merits of functional programming and Haskell from time to time.
Some of the guys over there have asked me which language I recommend they use to learn functional programming. Despite my liking Haskell very much, my answer is always the same: Scheme.
Haskell is a very nice language, it has a plethora of desirable features and it will positively influence other languages. However, Haskell is also a very complex language, there are many things in the language that stump people who want to pick it up (I had to try four separate times before I finally “clicked” with Haskell!) I do not find that it is suitable for someone who just wants to see what functional programming is about.
Let’s look at both languages side by side:
|Typing||Static typing. Though I am now convinced that a solid static typing system such as Haskell’s is a definite advantage when building software, it introduces a lot of complexity too. Inference, type classes, algebraic data types, existential types, phantom types, etc. That’s a lot of scary words and complexity for a newcomer, and static typing has nothing to do with learning the functional paradigm.||Dynamic typing. It doesn’t catch type mismatch problems before accepting to compile your program, but it’s very simple to use and has a very low mental requirement. Ideal for learning about something other than type systems. The error messages given at run-time by Scheme on type errors are simpler than Haskell’s often cryptic compile-time error messages.|
|Syntax||Haskell has a very beautiful syntax, but it’s a more complex one than Scheme’s. You need to be wary of operator precedence, layout rules (Haskell can be indentation-dependant) and other syntactic sugars which make Haskell nice to use when you know them, but can be a stumbling block when learning the language.||Scheme has one of the simplest syntax of any programming language. The rules can be explained in minutes. The syntax is unlike what most people are used to, especially if they come from a C-syntax background, but it’s easy to pick up and use.|
|Laziness||Haskell has lazy evaluation. Lazy evaluation has its benefits, which I will not discuss here, but it is harder to understand when something will happen.||Scheme has eager evaluation, which is what most programmers are used to and is easier to reason about.|
|Environment||The REPL of Haskell does not expose the entire language, it has limitations: for example, you can’t define functions or types as you would in your editor. So it can sometimes be little painful to test things interactively in GHCi.||DrScheme is an easy, friendly and free environment for Scheme that is ideal for learning. You can type anything you like in the REPL and Scheme will happily execute it. It also features an editing pane to write code and at the press of a button, the code in the pane is compiled. DrScheme also offers nice debugging and profiling tools.|
|Literature||Before “Real World Haskell”, there were not a lot of free, easily accessible books for Haskell on the Internet. Some of the newbie-oriented tutorials were actually quite daunting, making it hard to suggest reading material to somebody who wanted to learn functional programming.||Scheme has more books freely available on the Internet: “How To Design Programs” for people new to programming, Scheme and/or functional programming or the grand classic “Structure and Interpretation of Computer Programs” for the more serious and advanced students. “Teach Yourself Scheme in Fixnum Days” is somewhere in between. All books are of great quality and great value.|