typestar

Languages

OCaml

A functional language in the ML family, with type inference, pattern matching, and a strong module system.

Practice OCaml

29 steps across 1 tours, from the basics to complete programs.

The tours

First released
1996
Created by
Xavier Leroy and the Cristal team at INRIA
Typing
Static and fully inferred; immutable until spelled otherwise
Snippets target
5.5
File extensions
.ml, .mli

What it is for

OCaml is the ML family's production branch: Hindley-Milner inference so complete that type annotations are a documentation choice, variants and pattern matching the compiler audits for coverage, and a module system — signatures, functors — that remains the reference point every other language's module story gets compared against. The native-code compiler is genuinely fast, and the runtime got multicore support in its 5.0 rewrite.

Its most famous industrial user is Jane Street, which trades billions of dollars daily through OCaml and funds much of the ecosystem's tooling — dune, the de facto build system, among it. Beyond finance it is the language of language tools: Coq (now Rocq) is written in it, the first Rust compiler was, Flow and Hack came out of it at Meta, and a long lineage of type checkers, provers, and static analyzers keeps choosing it for the same reason — variants and matching make syntax trees a native data shape.

Its ideas travel farther than its market share: F# began as OCaml for .NET, ReasonML re-skinned it for JavaScript developers, and js_of_ocaml compiles it for the browser. The community is small, technical, and stable, with opam as the package manager and an unusually rigorous culture of interface-first design via .mli files.

Where it came from

OCaml descends from the original ML — Robin Milner's 1970s metalanguage for theorem provers — through INRIA's Caml (1985) and Caml Light. Xavier Leroy and the Cristal team released Objective Caml in 1996, adding an object layer to a fast native-code Caml; the objects saw modest use, but the compiler quality and module system made it the serious ML.

Through the 2000s it spread from research to industry: Jane Street standardized on it in the early 2000s and grew into the ecosystem's anchor tenant, while academia kept it as the implementation language of choice for proof assistants and compilers. The name simplified to OCaml, and opam (2013) plus dune (2018) modernized the toolchain.

OCaml 5.0 (2022) landed the largest change in its history: a multicore runtime with effect handlers, the product of nearly a decade of research engineering, delivered without breaking the sequential performance the community depends on. The language continues its steady cadence, with Jane Street's open-sourced libraries and INRIA's stewardship both still central.

What it is like to type

OCaml types like mathematics with a Unix accent: let and -> and |> carry most lines, almost no annotations survive inference, and pattern-matching arms line up under vertical bars. The distinctive frictions are deliberate: float arithmetic spells its own operators (+. and /.), refs read with ! and write with :=, and arrays index with .(i). Module-dot vocabulary — List.fold_left, Option.value, Printf.printf — lands constantly, and (* comments *) bookend in pairs. Terse, low on punctuation, high on arrows.

Practice OCaml

29 steps across 1 tours, from the basics to complete programs.

Official documentation

Other languages