July 3rd, 2005

  • evan

utility of ocaml

Now that I feel truly competent in O'Caml -- read a bunch of docs, written a bunch of programs, even contributed some code back the community -- I find that I'm not using it, and I've been puzzling over why.

  1. It fills a weird niche.
    It's much faster than a "scripting" language, much more fun to write than C++, but the cases where I've needed this sort of speed I've also needed the lower-level memory control of C++. (I refer you back to my entries about processing Wikipedia data, where I was streaming through large amounts of text and found my code spending most of its time in the GC. [I ought to fix this into a link.])

    This isn't to say that it isn't a niche that's useful -- see, for example, this fellow who appears to be implementing Katamari Damacy -- but just one that I haven't needed. (There seems to be a trend with OpenGL, probably because language speed attracts game developers.)
  2. The important derived question from the above is: is it more fun to write than a scripting language?

    And there, the answer is yes and no. In terms of concrete syntax and the way you express things, I think O'Caml's got the edge. Being able to write code without type annotations but retaining static typing is really a killer feature (coincidentally, the whole language is designed around it) for writing stable programs and iterating quickly.

    But there's an important caveat: the standard (and supporting) libraries are crap. There still isn't an obvious way for me to be able to make an HTTP request somewhere from within O'Caml. And I've read over and over about why standard libraries are one of the defining aspects of a language -- it's described as one of the distinguishing features of Python, which has a killer standard library -- but it hadn't sunk in as much because all of the languages I typically use have good standard libraries already. I read a comment somewhere to the effect of, "I don't program in Perl; I program in CPAN and use whatever language that requires."

    Even the C++ I write at work has a large standard library (see Joe Beda's post about Google's code organization), and it's been so long since I used C++ regularly I had forgotten it's not normally there. I've been writing something lately in C++ and I keep running into this: "OK, now I need to parse HTML. I'll just use... aw crap, I don't have that." But at least with C++ I can download libxml and use its HTMLparser. With O'Caml, I have to write the bindings myself.

    This sort of complaint (that O'Caml's developers don't take the broader language issues seriously, and instead focus on the lower-level bits) is regularly seen on the O'Caml lists. The developers respond by saying that the language is academic so that's basically the breaks. It's a startling contrast to the Haskell community, which is similarly academic, but where most major user-contributed projects are hosted by haskell.org and the developers are actively integrated into designing and implementing their own CPAN-like system, while simultaneously being aware of the needs of e.g. Debian-packaging requirements.
That last comment about Haskell is too bad, really: I think of Haskell as O'Caml with all the practicality removed, so if either of the languages needed a good standard library it'd be O'Caml.