On the Utility of Functional Programming
I have been using Haskell for about a year now (wow, has it really been that long?), and I think I have arrived at a point that I can talk about how useful it actually is with some level of credibility. It’s a question that comes up very often, mostly among imperative-only programmers and functional neophytes, but even a seasoned Haskell programmer might ask it from time to time.
The Haskell community suffers from a serious problem. There are very few large projects written in Haskell. There are very few libraries. There is very little use of Haskell in industry. There just isn’t much proof out there that Haskell is all that superior for somebody who wants to actually get something done. Before I finally decided to learn Haskell, I had poked around on Google on numerous occasions looking for some sort of evidence that it would be worth it. My conclusion almost every single time was that Haskell is nothing more than an academic language for academic people. I found the small examples amusing, such as the quicksort algorithm expressed as a couple lines of dense symbols and small variable names, but I never found anything significantly larger or more useful. Later, I heard about darcs, a distributed source code management system. It was the first time I had even heard of such a thing, so I decided to give darcs a shot to see if I liked it better than Subversion. I used MacPorts to install it, which usually compiles from source. Installing darcs took an extremely long time since I had to compile GHC first, and once it was installed, it turns out that darcs was, itself, extremely slow as well. This was the first time I had knowingly used anything written in Haskell. I made up my mind. Haskell was very, very slow, and would never be anything worth learning except as a mind exercise. Only a long time later, after I had already learned Haskell, did I learn that it wasn’t Haskell but the darcs “theory of patches” algorithm itself that was so slow.
Over the next couple years, I became more interested in programming language theory, so, inevitably, I became interested in functional programming once again. I had heard that OCaml was very fast, and since it was impure I had the impression that to catch on to it would be more natural for me, an imperative programmer, than a pure language like Haskell. I started through a couple tutorials, but never felt like I was learning anything ground-breaking. The syntax was surely different from what I was used to using, but the thinking process felt too similar. This did not line up with what I had heard about the way functional programming is supposed to open up your mind and whatnot. But weren’t monads supposed to be hard to learn and confusing to use? It didn’t make sense to me that purity was worth anything. I finally gave in. I learned Haskell.
I have gained a lot since then. I learned all kinds of neat stuff, like monads, generic algebraic data types, type classes, functional dependencies, purely functional IO, pattern matching, purity, and types as proofs. To a nonfunctional programmer, this list probably looks like a bunch of gobbledygook, but each of these concepts has expanded my mind. It was difficult, especially having to read academic papers just to feel like I had some notion of what each of these concepts meant at all, but I now have a strong interest in learning more, and there is oh so much more to learn! Functional programming has led me to a wondrous path of discovery.
My programming skills have definitely improved. I am a better programmer in every language I use because of Haskell. I use Haskell most of the time now though. It’s really not that bad. I get a lot done. I feel better about the code I write. I could even write a large application in Haskell without feeling like I am limited in some way. Haskell is, without a doubt, practical for every day use, far more so than any of the imperative language I have come across.
The only problem is that I find myself dissatisfied even with Haskell. I have finally been exposed to the wide open world of programming language theory, and all the numerous flaws of the popular (and unpopular) languages of today. The fun of programming has been stripped away from me because I have read and understood so many papers detailing better ways of doing everything. I no longer want to work on large projects, even in Haskell. I just want to further improve my Haskell skills, make Haskell better, find a better language, or make my own language from scratch.
This is the root of the problem. This is why, I think, there are not so many large Haskell projects out there. It’s just too tempting to make your skills and development environment even better now that you have caught a glimpse of the light. This only leads you farther and farther from reality into academia. It’s a black hole. The Haskell community certainly could write significant applications in Haskell, we just choose not to do so because there are so many opportunities for improvement. It takes a great deal of discipline to focus exclusively on the implementation of a project without being distracted by “what if I …,” “wouldn’t it be neat if …,” and “if only ….” Haskell, while leaps and bounds more enjoyable and productive than any of the imperative languages I know, has made me dissatisfied.
Very interesting!
I think the inwardly-focused nature of the community has changed a lot in the last couple of years, particular with the creation of hackage.haskell.org — having a centralised hosting, documentation and distribution framework has enabled hundreds of new libraries and tools in a short space of time, and helps encourage others in the community to contribute.
After all, almost all of the packages on hackage didn’t even exist a year ago, http://hackage.haskell.org/packages/archive/pkg-list.html
So I’m feeling quite hopeful, particularly with the growth in commercial support (places like Credit Suisse, Deutcsche Bank and Galois), that Haskell development will be self-sustaining, and lead to new projects. The Commercial User’s conference (http://cufp.galois.com) in 2007 was the largest yet (more than 100 attendees), and the first Jobs in FP recruitment event, (http://jobs-in-fp.org) occured in late 2007 — so I think the growth signs are positive.
And of course, the research community continues to play a key part in the development of the language, and infrastructure around it. It’s just not the only faction in the community any more: open source hackers and commercial contributors are playing an increasingly important part.
dons
January 12, 2008 at 10:37 pm
dons:
“almost all of the packages on hackage didn’t even exist a year ago”
Wow, I didn’t even notice that, but you’re right! Having only just jumped into the scene about a year ago, I haven’t much to compare the current state of things to the past. I would say that, based on the last year alone, the community certainly isn’t suffering, but Haskell still has a reputation among those not in the know of being weird and useless. Even my programming languages teacher said so last semester (I tried to set her straight, but she never corrected it for the rest of the class)!
Jake
January 12, 2008 at 11:23 pm
“Haskell still has a reputation among those not in the know of being weird and useless”
Stereotypes can be quite hard to break down, unfortunately. It takes a lot of code, and big public successes, to change the one line ‘tags’ people associate with new technologies.
But the open source community surrounding Haskell is definitely working on this, furiously. In 2007 alone, we held the:
* first 2 Haskell hackathons, http://www.haskell.org/haskellwiki/Hac_2007_II
* the first Haskell tutorials at OSCON, http://conferences.oreillynet.com/cs/os2007/view/e_sess/14016
* the creation of http://hackage.haskell.org, and some hundreds of new libraries
* cabal-install, an automated distribution tool to ease installation
* The first http://jobs-in-fp.org recruitment drive, as I mentioned.
* the creation of a dozen user groups across the globe, http://haskell.org/haskellwiki/User_groups
* the largest “commercial users” workshop yet
* the largest “haskell workhop” yet.
Coming up in 2008 there will be a range of “developer tutorials” at ICFP, following OSCON, yet more user groups, improved packaging and distribution tools. The focus is very outwards — moreso than at any time in its history.
The open source subset of the Haskell community, and the small commercial user base, will continue to create and push out projects, hopefully at an ever faster rate, as all the surrounding infrastructure comes in to play.
Also, for a perspective on what it was like in the past, see this comparison between the Haskell and Prolog communities recently published,
http://www.cs.kuleuven.ac.be/~dtai/projects/ALP/newsletter/dec07/content/Articles/tom/content.html
which illustrates sharply I think the change in the focus of the Haskell community over the past couple of years.
dons
January 12, 2008 at 11:53 pm