Monday, September 28, 2009

Installing Haskell

If we're going to be learning Haskell (which we are), we're going to need to install some stuff first. Head here (for just GHC) or here (for GHC with a bunch of extra libraries that you probably don't need). GHC, by the way, is the Glasgow Haskell Compiler, one of the two major implementations of the language. (The other is Hugs.) Download and install the file for whatever OS you're using. If you're on a Mac, you'll also need XCode before you can install GHC. (2.4 if you're on Tiger, 3.0 if you're on Leopard or Snow Leopard) So, while you're busy downloading that, I'm going to ramble on a bit about the language.

Haskell is a purely functional programming language developed in the late 1980s. Also, it's apparently a horse race.

The language takes its name from logician Haskell Curry, a really smart guy who has the interesting honor of having things named after him with both his first and last name - Haskell, a language called Curry (which was based on Haskell), the concept of currying, and Curry's paradox. His doctoral adviser was David Hilbert, another really smart guy who wanted to prove that mathematics was both complete and consistent. (Kurt Godel proved that it wasn't, thus probably making Hilbert's head explode, but that's not really relevant.)

A functional programming language treats functions as data. It's very easy to pass them as parameters to other functions and get them back as values of other functions.

A purely functional language is a functional language in which functions have no side effects. Calling the same function with the same parameters is guaranteed to always produce the same result. (This makes random numbers tricky. It's possible, but you have to cheat a bit.)

And, finally, a Hello, World program. (At least theoretically; I'm still wrestling with the compiler.)
UPDATE: The compiler has surrendered; victory is mine!

main = putStrLn "hello, world"


Yep. That's it.