Parallelism
Parallel programs must not introduce data races. OxCaml's type checker tracks which functions can run in parallel and how they may access captured mutable state.
OxCaml starts from OCaml's safe, high-level programming model and adds explicit, compiler-checked control over low-level behavior needed for high-performance code: allocation, memory layout, and parallelism.
OxCaml is still under active development. New features and changes are driven by concrete developer demand, especially from performance-sensitive applications.
Parallel programs must not introduce data races. OxCaml's type checker tracks which functions can run in parallel and how they may access captured mutable state.
A GC pause at the wrong time is unacceptable in low-latency code. OxCaml adds stack allocation, with type checking to ensure stack-allocated values do not outlive the stack frame that allocated them.
High-performance programs need cache locality, fewer pointer indirections, and fewer heap allocations. OxCaml uses types and layouts to give control over memory layout.
To allow this extra control safely, OxCaml adds several type system features.
x @ local, x @ shared, (unit -> unit) @ portable, f @@ portable — checked requirements on how a value may be used, such as whether it may outlive its region or whether a parallel function may read captured mutable state.stack_ expr, exclave_ expr — allocate temporary values without putting them on the heap.float#, #(x, y), #{ x : float# } — control memory layout.type t : value mod portable, ('a : value & immediate) — record what modes or layouts every value of a type can support.let%template, [@mode], [@kind] — generate related definitions across modes, kinds, and layouts.By the end of the course, you should be able to:
@ local, @ contended, @ portable, and layout annotations in real signatures;