At Jane Street, we’ve been actively making improvements to OCaml for a long time. Over the last few years, we’ve started to build some fairly ambitious extensions to the language. Our aim is to make OCaml a great language for performance engineering. This work has always been open source, and our hope is to contribute these extensions to upstream OCaml, but we’re still iterating on their design as we gain experience using them. As such, we think the time has come to make it easier for people to use our extensions in the outside world. That starts with giving our branch of the compiler the three most important components of a modern programming language: a cool name, a cute logo and a snazzy website. So, without further ado, we are excited to announce OxCaml.
We’ve also built a new website, oxcaml.org, that includes instructions for how to install OxCaml and some tutorials and documentation of the extensions to get you started.
A fast-moving set of extensions to the OCaml programming language
OxCaml is both Jane Street’s production compiler, as well as a laboratory for experiments focused towards making OCaml better for performance-oriented programming. Our hope is that these extensions can over time be contributed to upstream OCaml.
Design goals
OxCaml’s primary design goals are:
-
To provide safe, convenient, predictable control over performance-critical aspects of program behavior
-
but only where you need it,
-
and in OCaml!
What does this mean?
OxCaml’s extensions are meant to make OCaml a great language for performance engineering. Performance engineering requires control, and we want that control to be:
-
Safe. Safety is a critical feature for making programmers more productive, and for shipping correct code. Languages that are pervasively unsafe are too hard to use correctly.
-
Convenient. We want to provide control without bewildering programmers, or drowning them in endless annotations. To achieve this, we aim to maintain OCaml’s excellent type-inference, even as we add considerable expressiveness to the type-system.
-
Predictable. One of the great features of OCaml today is that it’s pretty easy to look at OCaml code and understand how it’s going to perform. We want our extensions to maintain and improve on that property, by making key performance details explicit at the type-level.
By “only where you need it”, we mean that OxCaml’s extensions should be pay-as-you-go. While OxCaml aims to provide more power to optimize, you shouldn’t need to swallow extra complexity when you’re not using that power.
By “in OCaml”, we mean that all valid OCaml programs are also valid OxCaml programs. But our more profound goal is for OxCaml to feel like OCaml evolving into a better version of itself, rather than a new language. For that, OxCaml needs to honor OCaml’s basic design sensibility, and to preserve the safety, ease, and productivity that are hallmarks of the language.
OxCaml’s extensions
Our extensions can be roughly organized into a few areas:
-
Fearless concurrency: Writing correct concurrent programs is notoriously difficult. OxCaml includes additions to the type system to statically rule out data races.
-
Layouts: OxCaml lets programmers specify the way their data is laid out in memory. It also provides native access to SIMD processor extensions.
-
Control over allocation: OxCaml gives programmers tools to control allocations, reducing GC pressure, making program behavior more cache efficient and deterministic.
-
Quality of life: OxCaml also contains some extensions that aren’t specifically about systems programming, but which we’ve found helpful in our day-to-day work:
OxCaml also builds on our Flambda2 middle-end, which improves on the performance of OCaml’s optimizer, and powers many of the extensions we need to make OxCaml’s new language features work.
Using OxCaml
OxCaml is open-source, and we’re excited to welcome experimental users, especially researchers and tinkerers who can kick the tires and provide feedback on the system. We put the emphasis on experimental because OxCaml makes no promises of stability or backwards compatibility for its extensions (though it does remain backwards compatible with OCaml).
OxCaml is intended to be easy to use, and to that end comes with modified versions of the standard OCaml tool-set, including:
- Package management, compatible with dune and opam
- Editor integration via the LSP-server
- Source code formatting
Jane Street has long open sourced a bunch of useful libraries and tools. These are now released in two forms: one for upstream OCaml, in which our extensions have been stripped, and one for OxCaml, where the extensions are fully leveraged.
Not all extensions are erasable, so some libraries will be available only for OxCaml. We’ll export OCaml-compatible versions of these libraries when the necessary extensions are integrated upstream.