Wednesday, August 15, 2007

Haskell: more than just hype?

Sometimes I wonder if the Haskell echo chamber is getting louder, or if programmers really are fed up with the status quo and slowly drifting towards functional programming. My hunch is that this is more than a mere echo chamber, and interest in Haskell and functional programming is for real.

I’m hardly an objective observer here, since I’m solidly within the echo chamber (note the name of this blog). Functional programming has been on my radar for at least a decade, when I first started playing with DSSSL. Coding with closures now feels more natural than building class hierarchies and reusing design patterns, regardless of the language I am currently using.

If you still aren’t convinced that Haskell is more than a shiny bauble lovingly praised by a lunatic fringe, here are some recent data points to consider, all involving Simon Peyton Jones:
  • Bryan O’Sullivan pointed out last week that the Simon’s talks are the most popular videos from OSCon:
    “Simon’s Haskell language talks are the most popular of the OSCON videos, and have been viewed over 50% more times than the next ten most popular videos combined.”

  • In Simon’s keynote presentation at OSCon last month, he points out that threading as a concurrency model is decades old, easy enough for undergraduates to master in the small, but damn near impossible to scale up to tens, hundreds or thousands of nodes. The research on threads has stalled for decades, and it’s time to find a better concurrency model that can help us target multiprocessor and distributed systems. (Nested data parallelism and software transactional memory both help, and are both available for experimentation in Haskell today.)

  • An interview with Simon and Erik Meijer that introduces the topic of nirvana in programming.

    Start by separating programming languages along two axes: pure/impure and useful/useless. The top left has impure and useful languages like C, Java and C#. The bottom right has pure and useless languages like Haskell (at least before monadic I/O). The sweet spot is the top right, where a pure, useful language would be found, if it existed.

    However, the C# team is borrowing heavily from Haskell to produce LINQ, and the Haskell research community is folding the idea back into Haskell in the form of comprehensive comprehensions. Both languages are slowly converging on nirvana: C# is getting more pure, and Haskell is getting more useful.

The subtext in all of these tidbits is that computing is not a static discipline. We know that hardware improves at a predictable pace, in the form of faster CPUs, cheaper memory, denser storage and wider networks.

Software, or at least the way we construct software, also improves over time. One unscientific way to express this is through relative differences in productivity between programming languages. It’s reasonable to expect a project to take less time to create when using Java instead of C, and even less time when using Ruby or Python instead of Java or C#.

By extension, there should be a new language that is even more productive than Python or Ruby. I happen to think that language will be Haskell, or at least very similar to Haskell. But it might also be OCaml, Erlang or Scala. In any case, Simon Peyton Jones is right — the way forward involves functional programming, whether it means choosing a language like Haskell, or integrating ideas from Haskell into your language of choice.


Anonymous said...

"I happen to think that language will be Haskell"

I am not sure. I think one of the biggest problems in Haskell, aside from it not being very easy (whats a monad?), is syntax.

Python and ruby syntax look rather similar, but haskell syntax is really something totally different to it.

Yes, this is a trival concept, but a language has to strive to be elegant, a very bad example of this is perl, which feels very 1980ish. And there are still people advocating to use the right tool for the job (translation: use shell scripts :P )

Aaron Denney said...

I tend to think that threading with shared memory is the wrong model., even if STM makes it more tolerable. Message-passing seems much closer to me, but I don't really know whether it will be like Haskell's Chans, MPI like, Erlang like, or what. Erlang does seem to scale very well...

Anonymous said...

I am watching the emerging functional baby with interest. I wonder which language is going to come out first. I see Haskell a lot, pushed somewhat by the success of Pugs (Perl6 interpreter). I see Erlang a lot now as well, be billed for its ability to scale easily and safely. I don't see a lot of Ocaml. I see a smidgen of Scala but that may grow as alternatives on the JVM grows. It will be interesting to watch and see.

Anonymous said...

Try F# (

Mark Leighton Fisher said...

Haskell will be important, if nothing else than for the influence it has had on Perl 6. Perl has had a couple of functional constructs for quite a while now (Perl 4?) -- grep() (pronounced "filter") and map(). Perl 6 is adding much functional goodness to the language, which will help to eliminate programmer state management when we don't really care about the state (again, think map and filter).

Computer languages have advanced by hiding away complexity except when we need to see it, and managing loop indexes etc. is boilerplate except when your loop has to do something based off of the index (much of time for me, that can be handled by a simple Boolean for detecting whether we are at the start of the loop or not). As I understand Haskell monads, they encapsulate state so the rest of your program (and your brain) does not have to care about state. The legacy of Haskell and its monads may be its influence on other languages rather than on the direct use of Haskell (similar to how I see the legacy of LISP).