OCaml — cover art: a wise camel in a deep-oxblood waistcoat and small wire-rim spectacles strides along a sunlit mountain pass, a brass instrument satchel over one shoulder and a small open notebook of mathematical glyphs in its forepaw. 🤓

2004 · Drunken Blog Rants · Note

“OCaml is a very high-level language, similar perhaps to Lisp or Prolog, but with strong type-checking that helps your programs run correctly the first time. However, it appears to be as fast or faster than C++, in any number of language shootouts.”
— From OCaml, June 2004
Read the essay

© 2004 Steve Yegge. Originally published at Drunken Blog Rants.

Author’s note

I believe this may have been my first-ever internal article inside Amazon, after having worked there for about 5 years. The company was coding primarily in Perl, C++, and Java, and I was unhappy with all of them. I felt like other languages held a lot of promise. OCaml I found to be particularly neat, because it took SML (a nifty pure-functional language) and made it practical with variable rebinding and such.

Ultimately I could not get other Amazon devs to take OCaml seriously. And back then it was so early for the language, almost no community, that I soon went back to Lisp.

Today, Jane Street, one of the world's first, largest, and most successful quant firms, uses OCaml extensively. They have taken it in-house and have been steadily advancing the language and compiler capabilities.

AI Notes

In mid-2004, Steve started learning OCaml because the Amazon Ph.D. candidates had been quietly raving about it for years and a handful of the best programmers he knew had named it their first choice. The claim: OCaml is as expressive as Lisp and as fast as or faster than C++. The ML family's type system lets the compiler deduce things a C++ compiler can't, which lets it stack-allocate heap memory, eliminate or inline virtual calls, exploit immutability for parallelism, and convert tail recursion to iteration. The context is Steve's year-long hunt for a Java replacement after hitting a wall around 600,000 lines of his own Java code — Perl, Python, Ruby, Lisp, Scheme, Standard ML, Haskell, Prolog, C#, Objective-C and others had each fallen short. OCaml, summer 2004, looked like the one with everything in one box: functional, imperative, OO, logic — all freely intermixed — plus Emacs support, an interactive interpreter, Win32 and Unix bindings, a real module system, and bindings to Oracle, MySQL, CORBA, COM, XML-RPC, SOAP. A footnote added in 2005 admits the candidacy didn't hold — he drifted back to Lisp.

Related listings

  • 2004

    More OCaml

    A month later — the follow-up Steve wrote because he kept finding things to like, capped by the reversible replay debugger that he refused to stop talking about.

  • 2005

    Lisp Wins (I think)

    A year later — the same year-long language tour from which the OCaml note is one stop, ending at Lisp instead of OCaml.

  • 2004

    Tour de Babel

    Same year — the broader survey this piece sits inside. Tour de Babel is the breadth; the OCaml notes are the depth on one of its more surprising entries.