The idea for the book was born in a bar in Tokyo in 2011. After a talk-filled day at ICFP, a few of us, Ashish Agarwal and Marius Eriksen, Anil, and myself, went out drinking. We were all bellyaching over the lack of a high-quality OCaml book in English, and, emboldened by the Guinness and egged on by Ashish and Marius, Anil and I decided that we were just going to have to go ahead and write the book ourselves. We brought Jason into the project soon after.
From the very beginning, Anil and I had different visions for the book. From my perspective, it was a simple proposition: there was no good book available, and we were going to write one. The goal was to document the state of the art so as to make it more accessible.
Anil’s vision was grander. He argued that writing a book is an opportunity to discover all of the things that are just too embarrassing to explain. And, once discovered, you needed to find a way to get all of those things fixed before the book was published. It was Anil’s grander vision that we followed, and to good effect. It’s not that we fixed the problems ourselves. We solved some problems directly, but by and large, we ended up getting help from those who were better positioned than us to fix the problems at hand.
Here are a few examples of pieces that came together over those two years.
- OPAM. The core work on OPAM was done by Thomas Gazagnaire at OCamlPro (funded by Jane Street), with Anil collaborating closely. This is probably the biggest improvement of the bunch. It’s hard to overstate how transformational OPAM is. Before OPAM, installing OCaml libraries was a complex chore. Now it’s a joy.
- The Core release process. We decided early on to base the book on Core, Jane Street’s alternative to OCaml’s standard library. But the release process around Core was too monolithic and too hard for external collaborators. We reorganized the process completely, moving to weekly releases to github, with the repos broken out into manageable components. Most of this work was done by Jeremie Dimino and Yury Sulsky at Jane Street.
- Ctypes. Anil was in charge of writing the section on C bindings, and he decided that the standard way was just too painful to explain. That was the germ of ctypes, a library, written by Jeremy Yallop, that lets you build C bindings entirely from within OCaml, with a easy and simple interface.
- Short paths. One of the real pains associated with working with Core is
the heavy use that Core makes of the module system. OCaml’s error messages,
unfortunately, do not cope with this terribly well, leading to absurd types
in error messages, so you might see a type rendered as
Core.Std.Int.Map.Key.t Core.Std.Option.Monad_infixwhere it could just as well have been rendered as
int option. We worked with Jacques Garrigue to implement a better heuristic for picking type names (suggested by Stephen Weeks, who implemented the same heuristic for Mlton). This is now available in the 4.01 version of the compiler, via the
This period also saw the founding of OCaml Labs, a lab at Cambridge University devoted to improving OCaml as a platform, with Anil at the head.
And we’re not done. OCaml Labs and OCamlPro are still working on improving OPAM and building out a curated OCaml Platform that’s built on top of OPAM. There’s ongoing work on improving documentation generation so we can have better online API docs. Jacques Garrigue and Leo White are working on adding module aliases to OCaml which will greatly improve compilation time for libraries like Core that need to manage large namespaces.
And there are more projects that are improving OCaml and its surrounding infrastructure that have no direct connection to Real World OCaml, like:
- Frederic Bour and Thomas Refis’ work on Merlin, a tool for providing IDE-like tooling from within editors like VI and Emacs.
- Mark Shinwell’s work on improving GDB support for OCaml,
- Fabrice le Fessant’s work improving OCaml’s interactions with performance tools like perf.
- Work that Ashish Agarwal, Christophe Troestler, Esther Baruk, and now many others, have poured into improving the http://ocaml.org website.
Real World OCaml is of course a personal milestone for Jason, Anil and myself (and for Leo White, Jeremy Yallop and Stephen Weeks, who made some key contributions to the text). But viewed from a broader perspective, it’s just one part of the increasing swirl of activity in the OCaml community.
OCaml has been a great language for a very long time. Now, we’re growing a social and technological infrastructure around it to match.