ML for the Working Programmer
In 1996, I arrived in Cambridge and, like countless other fresh university students, went about acquiring the prescribed stack of wincingly expensive textbooks. One - the key one for the Computer Science part of the course - bore the title ML for the Working Programmer1.
At the time, I thought nothing of this, but as my classmates and I learnt ML - the primary teaching language for undergraduates at the Computer Lab - we began to regard it as ironic overstatement, or perhaps protesting too much. Surely no working programmer would use this fussy, academic language? Unlike real languages such as C (or even BASIC), there was no way to access memory directly. You couldn’t circumvent the type system to get things done. You couldn’t even do something as simple as a
while loop; you had to tie yourself in knots with “tail recursion”, and hope that the compiler makes it efficient2.
By the time I’d graduated, I’d come to appreciate the elegance, expressiveness and power of ML, but still regarded it as a language for academics; something to influence other, more practical, languages perhaps, but not something I expected to see being used in the “real” world. But then, strange things started to happen.
The first hint that something was changing came from, of all places, Microsoft. In 2005, they adopted F# as an official language for their .NET platform. This new language3 was essentially a dialect of ML4.
A little while later, over on the open source side of the fence, there was an increase in interest in ML’s lazy compatriot Haskell at Red Hat and others. Interestingly, this wasn’t for solving hard problems with complex algorithms, where you might expect a more expressive language to be useful. Instead, it was for things like scripting and build automation, the most pragmatic of practical tasks. Academic languages were definitely getting their hands dirty.
In the past few years, things have picked up even more. The first time I looked at Rust, the closest thing to a viable C++ replacement I’ve yet to see, it was pleasantly familiar. More recently, Apple’s Swift has a distinctly ML-like flavour.
All of this is, in my opinion, very good news. Programming isn’t easy, and you need some kind of intellectual framework to navigate the near-infinite space of possibilities. The core ideas behind ML and friends have been polished in the river of academia for decades, and have become smooth and beautiful as a result. ML has a lot for the working programmer.
Spoiler: it does. [back]
Perhaps not coincidentally F# was developed at Microsoft Research Cambridge, at the time next door to the Computer Lab. [back]
Not the Standard ML I’d learnt as an undergraduate, but its close relative OCaml. Perhaps it’s just early exposure, but I’ve never been keen on the latter’s syntactic quirks. Semicolons as list separators? Sacré bleu! [back]
In fact, C++ has had at least one feature taken directly from ML almost since its inception. Don’t like exceptions? Blame ML. [back]
Arguably LISP-like, but I’d say that that would imply macros. Perhaps Scheme-like, but Scheme and ML are very similar in many respects. [back]