OCaml in Teaching & Research

With its deep mathematical roots, OCaml has has always had strong ties to academia. It is taught in universities around the world, and has accrued an ever growing body of research.

Top Universities Teach OCaml

University of Cambridge

The University of Cambridge is a collegiate research university in Cambridge, United Kingdom.

Foundations of Computer Science

Lecture Notes

Advanced Functional Programming

Harvard University

Harvard University is a private Ivy League research university in Cambridge, Massachusetts. higher education academy.

Principles of Programming Language Compilation

Lecture Notes

Video Recordings

Introduction to Computer Science II- Abstraction & Design

Cornell University

Cornell University is a private, statutory, Ivy League and land-grant research university in Ithaca, New York.

Data Structures and Functional Programming

Lecture Notes

Video Recordings

University of California, San Diego

The University of California, San Diego(UC San Diego or, colloquially, UCSD) is a public land-grant research university in San Diego, California.

Université Paris Cité

Université Paris Cité is a multidisciplinary research university in Paris, France, known for its strong emphasis on innovation, international collaboration, and a broad range of academic programs across sciences, humanities, and social sciences.

Introduction to Functional Programming
Functional Programming for the Web
Functional Programming
Virtual Machines

Lecture Notes

Compilation
Static Analysis
Advanced Functional Programming

Lecture Notes

Advanced Functional Programming

Lecture Notes

Many more academic institutions teach OCaml!

Research Papers

Understand the theoretical foundations of the OCaml programming language and compiler

Retrofitting Effect Handlers Onto OCaml

Effect handlers have been gathering momentum as a mechanism for modular programming with user-defined effects. Effect handlers allow for non-local control flow mechanisms such as generators, async/await, lightweight threads, and coroutines to be composably expressed. We present a design and evaluate a full-fledged efficient implementation of effect handlers for OCaml, an industrial-strength multi-paradigm programming language. Our implementation strives to maintain the backwards compatibility and performance profile of existing OCaml code. Retrofitting effect handlers onto OCaml is challenging since OCaml does not currently have any non-local control flow mechanisms other than exceptions. Our implementation of effect handlers for OCaml: (i) imposes a mean 1% overhead on a comprehensive macro benchmark suite that does not use effect handlers; (ii) remains compatible with program analysis tools that inspect the stack; and (iii) is efficient for new code that makes use of effect handlers.

K. C. Sivaramakrishnan, Stephen Dolan, Leo White, Tom Kelly, Sadiq Jaffer, Anil Madhavapeddy

PLDI
effects

Extending OCaml's `open`

We propose a harmonious extension of OCaml's `open` construct. OCaml's existing construct `open M` imports the names exported by the module `M` into the current scope. At present `M` is required to be the path to a module. We propose extending `open` to instead accept an arbitrary module expression, making it possible to succinctly address a number of existing scope-related difficulties that arise when writing OCaml programs.

Runhang Li, Jeremy Yallop

ocaml-workshop
core
language

Bounding Data Races in Space and Time

We propose a new semantics for shared-memory parallel programs that gives strong guarantees even in the presence of data races. Our local data race freedom property guar- antees that all data-race-free portions of programs exhibit sequential semantics. We provide a straightforward oper- ational semantics and an equivalent axiomatic model, and evaluate an implementation for the OCaml programming language. Our evaluation demonstrates that it is possible to balance a comprehensible memory model with a reasonable (no overhead on x86, ~0.6% on ARM) sequential performance trade-off in a mainstream programming language

Stephen Dolan, KC Sivaramakrishnan, Anil Madhavapeddy

PLDI
multicore

What Researchers Say About Ocaml

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. No interaction with the maintainers at INRIA was required.)

Scott, D. & Sharp, R. & Gazagnaire, T. & Madhavapeddy, A.(2010)

Journal of Cheminformatics volume 11, Article number: 10

To us, OCaml has been proven quite productive for software prototyping in Chemoinformatics and Structural Bioinformatics method development. The software demonstrated here was used intensively and timely during scientific validation campaigns, on many molecules and protein targets. We have never regretted our choice of OCaml and still use it today.

Francois Berenger , Kam Y. J. Zhang and Yoshihiro Yamanishi.(2019)

ACM SIGPLAN Notices. 45. 87-92. 10.1145/1863543.1863557.

Recommended Books

RECOMMENDED BOOK

OCaml Programming: Correct + Efficient + Beautiful

Beginner

This textbook, used in a third-semester Cornell course, teaches functional programming and data structures in OCaml, emphasizing semantics and software engineering. Suitable for students with Python and Java backgrounds, it requires some imperative language skills and basic discrete mathematics. The book includes over 200 YouTube videos as supplementary or alternative learning resources.

RECOMMENDED BOOK

Programming Well: Abstraction and Design In Computation

Beginner

This textbook uses OCaml as the primary language to explore different programming paradigms - imperative, functional, and object-oriented. Through OCaml's multi-paradigm nature, readers learn to solve problems in different ways, considering aspects like correctness, efficiency, readability, and elegance. Suitable for those with basic programming experience, it builds on introductory concepts to examine the difference between programming and programming well.

View all books (17)

Industry

Curious about How OCaml is Used in Industry?

Go to our success stories to see how businesses use OCaml.