OCaml Labs
I founded a research group called OCaml Labs at the University of Cambridge, with the goal of pushing OCaml and functional programming forward as a platform, making it a more effective tool for all users (including large-scale industrial deployments), while at the same time growing the appeal of the language, broadening its applicability and popularity. Over a decade, we retrofitted multicore parallelism into the mainline OCaml manager, wrote a popular book on the language, and helped start and grow an OCaml package and tooling ecosystem that is thriving today.
Background
In my PhD work on
It was around this time in 2011 that my work on
Early Days (2012-2014)
In 2012, we launched the centre from the Cambridge Computer Lab in
- publishing
Real World OCaml: Functional Programming for the Masses with O'Reilly, which sold lots of copies in the early days and created plenty of buzz for OCaml. It was quite fun attending author signings around the world and having lines of people queuing up for a signature! - I worked closely with
Thomas Gazagnaire (then CTO at OCamlPro) who lead the development of the first version of the opam package manager. Both of us were also establishing the MirageOS project at the time, and so we ended up bootstrapping a big chunk of the opam-repository for use by it, and we also took a (in hindsight excellent) decision to use the nascent GitHub platform as the primary mechanism for managing packages instead of hosting a database. After a few releases in 2012 and thenOPAM 1.1 beta available, with pretty colours , the package manager rapidly established itself as the defacto standard for the OCaml ecosystem. I've been the chief maintainer of the opam-repository ever since then (with many wonderful co-maintainers who do much of the heavy lifting, of course!). As of 2021, there are over 20000 packages in the repository. I've been less active since about 2023, but still the repository administrator.
We also began organising community events, both online and offline:
- Didier Remy and I organised the inaugral OCaml Users and Developer's workshop in 2012, which morphed in subsequent years into the OCaml Workshop. See
Camel Spotting in Paris for an earlier user group meeting as well. - Cambridge Compiler Hacking sessions ran from 2013 to 2017 and served as introductions to new developers with experienced mentors on hand.
- the conference highlight of the year were undoubtedly the CUFP workshops at ICFP as they combined a really active academic and industrial crowd. The writeups are in
CUFP 2011 Workshop Report ,Commercial users of functional programming workshop report andCUFP'13 scribe's report to give you a sense of what went on. - we worked with Ashish Agarwal and Christophe Troestler to develop a brand new website to replace the original https://caml.inria.fr one, and this eventually became ocaml.org in around 2012. Almost a decade later, I announced the replacement of this one with a v3 version as well.
- helping to open up OCaml compiler development by improving the GitHub infrastructure and starting the
ocamlorganisation there, such as via OCaml/GitHub integration. Eventually, compiler development moved over entirely to GitHub thanks to a big push from the core developer team.
There was enough activity in the early days that I managed to capture it in annual blog posts:
Reviewing the first year of OCaml Labs in 2013 Talks from OCaml Labs during ICFP 2014 Reviewing the second year of OCaml Labs in 2014
After 2014 though, things had grown to the point where it was just too difficult for me to keep up with the flurry of movement. We then aggregated into a "middle age" research project around 2015 with the following projects that would take the next few years.
The OCaml Platform
One of the main thrusts in OCaml Labs was to construct the tools to enable effective development workflows for OCaml usage at an industrial scale, while remaining maintainable with a small community that needed to migrate from existing workflows. This effort was dubbed the "OCaml Platform" and really picked up stream after our release of the opam package manager, since it began the process of unifying the OCaml community around a common package collection.
While much of the work was lead from OCaml Labs, it's also been highly collaborative with other organisations and individuals in the community. And of course, 100% of the work was released as open source software under a liberal license. I've been giving annual talks since 2013 or so about the steady progress we've been making towards building, testing, documentation and package management for OCaml.
Real World OCaml: Functional Programming for the Masses was the book published by O'Reilly that explained how to use OCaml with the Core library.- My 2013 talk on
The OCaml Platform v0.1 first introduced the OCaml Platform just after opam was first released. - My 2014 talk on
The OCaml Platform v1.0 continued the steady adoption of opam within the OCaml community, to start bringing a standard package database across the different users. - My 2015 Platform talk then introduced continous integration for opam, as well the start of the central documentation efforts (which were finally completed in 2021 after some herculean efforts!).
- By my 2017 Platform talk in Oxford, we had most of the OCaml community using opam and released opam 2.0, started contributing to the new jbuilder build tool from Jane Street, and began the shift from camlp4 to ppx and the development of the new odoc tool.
- In my 2018 Platform talk in Missouri, we had helped evolve jbuilder into the Dune build system (now the build tool of choice in OCaml), and started to combine packaging and build into a cohesive platform. The key challenge so far had been to fill in gaps in functionality, and now we could begin to weave together the components we'd built.
- My 2019 Platform talk in Berlin focussed on how workflows using all these tools would work, such as for package managers or application developers or end users.
- My 2020 Platform talk saw the unveiling of the VSCode OCaml Platform plugin, which provided a seamless integration with the IDE to let all the workflows and tools from earlier years "just work" out of the box.
- In 2021, we embarked on a huge mission to rebuild the ocaml.org online presence with a central documentation site that built 20000 packages with cross-referenced HTML documentation.
As you can see, it's quite a journey to build community-driven development tools. A key to our approach was to "leave no OCaml project behind", and we spent considerable effort ensuring that every step of the tooling evolution had a migration path for older OCaml projects. As a result, it's often still possible to compile 20 year old OCaml code using the modern tooling.
Multicore OCaml
The other big research project we drove from OCaml Labs was the effort to bring multicore parallelism to OCaml. While this might seem straightforward, we quickly realised that the challenge was in preserving existing sequential performance while also allowing new code to take advantage of multicore CPUs.
The first talk we gave was in 2014 on
- Any multicore-capable language needs a well-defined memory model, and we realised that none of the existing ones (e.g. in C++ or Java) were particularly satisfactory. Our PLDI paper on
Bounding data races in space and time defined a sensible and novel memory model for OCaml that was predictable for developers. - Our garbage collector and runtime design won the best paper award at ICFP for its systematic approach to the design and evaluation of several minor heap collectors, in
Retrofitting parallelism onto OCaml .
Algebraic Effects
While working on parallelism in OCaml with
- The
Effectively tackling the awkward squad andConcurrent System Programming with Effect Handlers papers were our first forays into using the effect system for realistic usecases such as Unix systems programming. - We then spent a few years engineering a full production-quality version of runtime fibres in
Retrofitting effect handlers onto OCaml , again with a focus on maintaining tooling compatibility (e.g. with debuggers) and also having a minimal impact on sequential performance for existing code.
In around 2020, I started publishing multicore monthlies on the OCaml discussion forum. This was because we had begin the journey to upstream our feature into the mainline OCaml compiler. At the end of 2020,
OCaml Labs to Tarides (2021-present)
The OCaml Labs research project at the University of Cambridge finally came to
a happy end in 2021, after almost ten years. After the first decade of fundamental
research and early engineering, the maintainership and stewarding of the resulting code has only
picked up pace as the OCaml userbase grows. There are now three commercial
companies who have taken over the work from the University, all run by research
staff originally in the Computer Lab group (
- OCaml Labs Consultancy is based in Cambridge in the UK.
- Tarides is based in Paris, France.
- Segfault Systems is based in Chennai, India.
All of those groups merged into one unified Tarides in 2022 (OCLC and Segfault), making it easier to manage a growing community of maintainers. There's really exciting work happening there to continue the upstreaming of the multicore OCaml features into mainline OCaml, making unikernels and MirageOS ever more practical and robust to deploy, and shipping end-to-end Windows support in the OCaml toolchain. You can read about all this and more on the Tarides blog, which is regularly updated with news on their projects.
Activity
Jane Street and Docker on moving to OCaml 5 at ICFP/SPLASH 2025 – Research note (Oct 2025)
Reviewing the second year of OCaml Labs in 2014 – Research note (Apr 2015)
Announcing OCaml Labs – Research note (Oct 2012)
Unikernels – Project (2010–2019)
Personal Containers – Project (2009–2015)
References
Paper in the the 10th ACM OCaml Users and Developers Workshop.
Retrofitting parallelism onto OCaml
KC Sivaramakrishnan, Stephen Dolan, Leo White, Sadiq Jaffer, Tom Kelly, , Sudha Parimala, , and Anil Madhavapeddy.
Journal paper in Proceedings of the ACM Programming Languages (vol 4 issue ICFP).
Anil Madhavapeddy, and .
Paper in the proceedings of the OCaml Workshop 2019.
A modular foreign function interface
Jeremy Yallop, , and Anil Madhavapeddy.
Journal paper in Science of Computer Programming (vol 164).
The State of the OCaml Platform: Sep 2017
Paper in the the 7th ACM OCaml Users and Developers Workshop.
Effectively tackling the awkward squad
Stephen Dolan, Spiros Eliopoulos, , Anil Madhavapeddy, KC Sivaramakrishnan, and Leo White.
Paper in the the ACM ML Workshop.
Mergeable persistent data structures
, Thomas Gazagnaire, and Anil Madhavapeddy.
Paper in the vingt-sixiemes Journees Francophones des Langages Applicatifs (JFLA 2015).
Raft Refloated: Do We Have Consensus?
, Malte Schwarzkopf, Anil Madhavapeddy, and Jon Crowcroft.
Journal paper in ACM SIGOPS Operating Systems Review (vol 49 issue 1).
Marius Eriksen, Michael Sperber, and Anil Madhavapeddy.
Journal paper in Journal of Functional Programming (vol 25).
Stephen Dolan, Leo White, and Anil Madhavapeddy.
Paper in the the 4th ACM OCaml Users and Developers Workshop.
Anil Madhavapeddy, , , Thomas Gazagnaire, , Thomas Leonard, , Mark Shinwell, Leo White, and Jeremy Yallop.
Paper in the the 4th ACM OCaml Users and Developers Workshop.
Irminsule: a branch-consistent distributed library database
Thomas Gazagnaire, , Jon Crowcroft, Anil Madhavapeddy, Richard Mortier, Dave Scott, , and .
Paper in the the 4th ACM OCaml Users and Developers Workshop.
Commercial users of functional programming workshop report
Michael Sperber, and Anil Madhavapeddy.
Journal paper in Journal of Functional Programming (vol 23 issue 6).
, Anil Madhavapeddy, , and Thomas Gazagnaire.
Paper in the the 3rd ACM OCaml Users and Developers Workshop.
Anil Madhavapeddy, , Thomas Gazagnaire, , , Leo White, and Jeremy Yallop.
Paper in the the 2nd ACM OCaml Users and Developers Workshop.
Programming the Xen cloud using OCaml
Dave Scott, Richard Sharp, and Anil Madhavapeddy.
Paper in the the 1st ACM OCaml Users and Developers Workshop.
Anil Madhavapeddy, Yaron Minsky, and Marius Eriksen.
Journal paper in Journal of Functional Programming (vol 22 issue 1).
Dynamics for ML using Meta-Programming
Thomas Gazagnaire, and Anil Madhavapeddy.
Journal paper in Electronic Notes in Theoretical Computer Science (vol 264 issue 5).