OxCaml - a set of extensions to the OCaml programming language.

Jun 13, 2025 - 16:15
 0  0

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!

Let’s talk about what this means!

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 and making programs 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:

  • Polymorphic parameters
  • Include functor
  • Labeled tuples
  • Immutable arrays

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
  • Documentation generation

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.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0