What are the pros and cons of learning Haskell as a first programming language?

Quora Feeds

Active Member
Tikhon Jelvis

In general, Haskell is a good language to learn first. It's already used by a few universities in their intro sequences.

I've found it does a really good job of teaching good style. Your code is naturally modular, simple and self-contained, breeding habits you can take with you to other languages.

Haskell also scales well in ideas. You start out with very simple expressions in a REPL (interactive prompt) but it can then grow to both higher-level and lower-level ideas. On the one hand, Haskell is naturally a great place to learn about PL theory and a bit of mathematics. On the other, it's also great for parallel and concurrent programming and even gives you a surprising amount of control (at least in GHC) over things like how your types are laid out in memory. People deride highly optimized Haskell for looking too low-level, but this just shows how much breadth it has as a language.

Haskell starts out at about the same level as Python but easily encompasses both lower- and higher-level ideas as well.

Anecdotally, Haskell is actually pretty easy to pick up as a first language. Many of the problems people have learning Haskell come from how different it is: Haskell subverts your imperative expectations. But if you don't know anything about programming at all, you don't have any expectations to subvert! It also seems to be easier to go from Haskell to something else than vice-versa.

However, there are a handful of problems. The biggest one is incidental complexity. Haskell the language is great, but its tooling, its error messages and its build system are all more complex than they have to be. GHCi is a fine REPL—and having a REPL is crucial for a beginner's language—but it doesn't work quite like normal Haskell code. Error messages are often... not great.

Happily, some of this is currently being worked on. The Haskell Platform, around for a while, makes installation much easier. IHaskell offers a better, more consistent REPL experience. The package management infrastructure (Hackage and Cabal) have recently improved significantly, and are still improving. The Emacs mode is due to get some improvements and new features soon as well.

It's not nearly as bad as it could be, but it's still much harder to get started with Haskell compared to something like JavaScript or Python that's already installed.

Haskell, considering its extensions, is also a relatively large language. It's not Scala or C++, but it really isn't Scheme either. This is partly offset by its design: all of the features collapse pretty elegantly into a tiny λ-calculus without too many features. But in practice, it does mean that you will not learn how to use the whole language—you'd probably want somebody to curate it for you.

The final problem I can see is that visual libraries (like UI toolkits) are a bit lacking. These are the things that give people immediate feedback and make learning more fun. It's harder to make a game in Haskell than JavaScript not because of the language itself but because it lacks UI libraries. To some extent, this is getting easier: there are projects to compile Haskell to JavaScript and nice little UI libraries designed for ease-of-use like threepenny-gui. I think you could also have a lot of fun with diagrams which makes doing pictures and visualizations easier, drawing cool pictures like this:
main-qimg-c753c29abfd307188f2961821b306de1



So in general, I think Haskell is a great first language to learn, I'm just worried that it might take more effort to get up and going because of the tools issues, especially if you want to make something visually striking or interesting to play with.

If I was going to teach people to program with Haskell, I would put some effort up front to make the installation and setup process painless. Get people easily set up with Emacs, make sure the install the right version of the Haskell platform, demo the workflow of both loading modules in GHCi and compiling them and so on. I think that by itself would much of the frustration with stating with Haskell.

See Questions On Quora

Continue reading...
 
Top