OxCaml Basics

OxCaml Basics

A three-hour course for Jane Street interns and engineers about safe high-performance OxCaml: checked stack allocation, control over runtime representation, and parallelism.

Each section page starts with the lecture notes and ends with the exercises. If you attended the lecture, jump straight to the exercises at the end of each page.

  1. 00

    Why OxCaml exists

    Why ordinary OCaml is not always enough for high-performance code, and which OxCaml features this course will cover.

    10 min · motivation

  2. 01

    Locality and stack allocation

    How local values, stack_, and exclave_ help control heap allocation and lifetime.

    45 min · allocation

  3. 02

    Value layouts and unboxing

    Uniform OCaml values first, then the costs of boxes and pointers, then layouts, unboxed values, or_null, and a short note on templates.

    45 min · representation

  4. 03

    Parallelism: contention and portability

    How to run callbacks in parallel without data races when they receive explicit arguments or close over mutable state.

    80 min · parallelism

  5. deck

    Lecture slides

    Slides for teaching the course, with OxCaml examples, exercises, and speaker notes.

    slides · exercises