August 18th, 2006

  • evan

why type classes are interesting

One of Haskell's distinguishing (and perhaps unique) language features is called "type classes", which can be especially confusing because the word "class" has a strong meaning to most of us already. So here's a description of what they are, and why I think they're interesting.

Collapse )
  • evan

speed is not an excuse

What first got me down this wacky programming-languages path was getting curious about O'Caml and its reputation for speed. Then, as an O'Caml programmer who had heard about how all the cool kids were talking about Haskell, I had avoided it because it had to be slow (strings are linked lists!).

It turns out that in completely flawed microbenchmarks, Haskell ends up being in the general range of "decently fast" -- comparable to Java and often orders of magnitude faster than than "good enough" languages like Python or Perl. (Poor Ruby is almost reliably the slowest, often by a factor of a hundred.)

There are a few lessons here: the first, of course, is that microbenchmarks are not especially meaningful. Another is that you can uglify up Haskell code to make it fast if you want to.

But the important one is that the standard "premature optimization is the root of all evil" argument still applies, even when strings are implemented as linked lists. Ruby is obviously fast enough for plenty of projects. What ultimately matters more is what will get your job done the quickest.