OCaml
An industrial-strength functional programming language with an emphasis on expressiveness and safety
# let square x = x * x
val square : int -> int = < fun >
# square 3
- : int = 9
# let rec fac x =
if x <= 1 then 1 else x * fac (x - 1)
val fac : int -> int = < fun >
# fac 5
- : int = 120
# square 120
- : int = 14400
The OCaml Compiler has been recognised by SIGPLAN for their prestigious Programming Languages Software Award
Trusted by Industry Leaders
Why OCaml?
RELIABILITY
Powerful Type Safety Made Simple
First-Class Editor and Tooling
odoc
,
an easy-to-use documentation generator, OCaml programmers have access to a complete, modern developer experience.
PERFORMANCE
Fast Compiler and Applications
Exceptionally Robust and Reliable
Despite all this testing, we have never had a single XenServer defect reported from internal testing or from the field that can be traced back to a bug in the OCaml runtime or compiler. (During development we did once find a minor compiler bug, triggered when compiling auto-generated OCaml code with many function arguments, but this was already fixed in the development branch by the time we reported it and so no interaction with the maintainers at INRIA was required.)-- Scott, D. & Sharp, R. & Gazagnaire, T. & Madhavapeddy, A. (2010). Using Functional Programming within an Industrial Product Group: Perspectives and Perceptions. ACM SIGPLAN Notices. 45. 87-92. 10.1145/1863543.1863557.
Releases
5.1.0 (2023-09-14)
- Many runtime performance regression and memory-leaks fixes (dynlinking, weak array, weak hash sets, GC with idle domains, GC prefetching)
- Restored support for native code generation on RISC-V and s390x architectures
- Restored Cygwin port
- Reduced installation size (50% reduction)
- Compressed compilation artefacts (.cmi, .cmt, .cmti, .cmo, .cma files)
- 19 error message improvements
- 14 standard library functions made tail-recursive with Tail-Recursion-Modulo-Cons (TRMC), such as
List.append
andList.map
- 57 new standard library functions
- More examples in the standard library documentation
- 42 bug fixes
The OCaml Ecosystem








Users of OCaml
For Educators
For Industrial Users
Curated Resources
Getting Started
Install OCaml, set up your favorite text editor and start your first project.
Language Manual
Read the reference manual of the language and documentation on the compiler.
Books
Discover OCaml books from expert programmers and researchers - from beginner level to advanced topics.
Standard Library
Searchable API documentation.
Exercises
Learn OCaml by solving problems on a variety of topics, from easy to challenging.
Papers
Explore papers that have influenced OCaml and other functional programming languages.
OCaml Packages
Explore thousands of open-source OCaml packages with their documentation.
