I am building a course, “Functional Programming with OCaml”, for the NPTEL MOOC platform: twelve modules of recorded lectures. The course book is not a PDF and not a website with code listings you copy elsewhere. It is a website where the code runs, in your browser, with nothing installed and no server behind it. The first half is OCaml; the last few modules cross into OxCaml. An O(x)Caml book,…
In the previous post on capsules, I cheated. The lecture I was adapting (from my CS6868 course on language abstractions for parallelism) used Await_capsule.Mutex.with_lock , the recommended non-deprecated way to acquire a capsule mutex, but the post shipped Capsule_blocking_sync.Mutex instead with the deprecation alert silenced. The reason was bundle size: the await library, once we chased its…
In the previous post we fixed the racy gensym with Portable.Atomic . That worked because the shared state was a single integer with atomic primitives. What about state that needs a hash table, a multi-step update, or any structure where atomics aren’t enough? OxCaml’s answer is the capsule : a way to bundle state with its lock so the lock discipline becomes a type-checker job rather than a…
A while back I wired up x-ocaml so this blog could embed live, editable OCaml notebooks. That post used a vanilla OCaml 5 toplevel. Today the toplevel running in your browser is built from OxCaml , the Jane Street fork of the compiler. That means we can prove a small parallel program is data-race free, interactively, without ever spawning a thread. The examples below are adapted from the OxCaml…
What does it mean for a replicated data type to be correct ? For most of the literature, my own prior work included, the answer has been convergence: two replicas that have applied the same operations end up in the same state. I argued in my PaPoC 2026 keynote last week that for many useful data types convergence is not enough, and agentic proof-oriented programming can help close the gap between…
How do you acquire the fundamental computer skills to hack on a complex systems project like OCaml? What’s missing and how do you go about bridging the gap? There are many fundamental systems skills that go into working on a language like OCaml that only come with soaking in systems programming. By systems programming, I mean the ability to use tools like the command-line, editors, version…
Can we have OCaml notebooks as pure client-side code? Can these notebooks have rich editor support (highlighting, formatting, types on hover, autocompletion, inline diagnostics, etc.)? Can you take packages from OPAM and use them in these notebooks? The answer to all of these turns out to be a resounding yes thanks for x-ocaml . This post is my experiment playing with x-ocaml and integrating that…
In the last post , we looked at uniqueness mode and how uniqueness may be used to optimise. As we will see, uniqueness alone is insufficient in practice, and we also need a concept of linearity for uniqueness to be useful. Capturing unique values Let’s start with an example. Recall the signature of the unique reference module. module type Unique_ref = sig type ' a t val alloc : ' a -> ' a t @…
Jane Street has been developing modal types for OCaml – an extension to the type system where modes track properties of values, such as their scope, thread sharing, and aliasing. These modes restrict which operations are permitted on values, enabling safer and more efficient systems programming. In this post, I focus on the uniqueness mode, which tracks aliasing, and show how it can eliminate…
Recently, I posted on X and LinkedIn that I am always looking for excellent people to join my group. I received a lot of enquiries, some of which led to internship hires (yay!). But mostly, I seemed to offer similar advice. I thought I’d write a post that summarise my responses. At IIT Madras, my research group develops programming language abstractions to solve systems problems. The group is…
Off-CPU analysis is where the program behavior when it is not running is recorded and analysed. See Brendan Gregg’s eBPF based off-CPU analysis . While on-CPU performance monitoring tools such as perf give you an idea of where the program is actively spending its time, they won’t tell you where the program is spending time blocked waiting for an action. Off-CPU analysis reveals information about…
A number of folks who regularly use OCaml were surprised to learn that you can reasonably debug OCaml programs using gdb. The aim of the post is to show the first steps in using gdb on OCaml programs. Let’s consider the following program: (* fib.ml *) let rec fib n = if n = 0 then 0 else if n = 1 then 1 else fib ( n - 1 ) + fib ( n - 2 ) let main () = let r = fib 20 in Printf . printf "fib(20) =…
Last semester at IIT Madras, I taught a revamped core course CS3100 Paradigms of Programming , which introduces 3rd-year students to functional and logic programming paradigms. While the course had been traditionally offered in Lisp and Prolog, I introduced OCaml instead of Lisp. All of the lectures were delivered through interactive Jupyter notebooks. The assignments were also distributed as…
Multiple Research Software Engineer positions are available in the Department of Computer Science and Engineering at the Indian Institute of Technology, Madras to develop Multicore OCaml and enable Tezos ecosystem to benefit from Multicore OCaml. A dog, a deer and a monkey walk into a coffee shop... Background The Multicore OCaml project aims to add native support for scalable concurrency and…
Multicore OCaml comes with a concurrent garbage collector , where the garbage collector and the mutator threads run concurrently. Debugging concurrent GC bugs has been the most frustrating / satisfying (when fixed) part of Multicore OCaml development. rr , a record and replay tool has made debugging concurrent GC bugs a sustainable exercise. In this short post, I’ll describe why. A particularly…
I am chairing the PC for ML family workshop this year. The PC is happy to invite submissions for the workshop to be held during the ICFP conference week on Thursday 22nd August 2019. ML family workshop invites submissions touching on the programming languages traditionally seen as part of the “ML family”. However, we are also keen to receive submissions from other related language groups. If you…
It has been 3 months since I joined IIT Madras and it has been good fun so far. Along with the members of the RISE group , we’ve initiated a project to build secure applications on top of secure extensions of the open-source Shakti RISC-V processor ecosystem. Unsurprisingly, my language of choice to build the applications is OCaml . Given the availability of rich ecosystem of libraries under the…
Over the past few weeks, at OCaml Labs , we’ve deployed continuous benchmarking infrastructure for Multicore OCaml . Live results are available at http://ocamllabs.io/multicore . Continuous benchmarking has already enabled us to make informed decisions about the impact of our changes, and should come in handy over the next few months where we polish off and tune the multicore runtime. Currently,…
Andrej Bauer and I are editing a special issue of JFP on the theory and practice of algebraic effects and handlers. The CfP is below. CALL FOR PAPERS JFP Special Issue on The Theory and Practice of Algebraic Effects and Handlers Submission Deadline: 18 January 2019 Expected Publication Date: December 2019 Scope An important aspect of real-world languages is their support for computational effects…
I recently gave a talk on the internals of multicore OCaml GC at Jane Street offices in NYC. The slides from the talk are available online . But I felt that the slides alone aren’t particularly edifying. This post is basically the slides from the talk annotated with notes. Abstract In a mostly functional language like OCaml, it is desirable to have each domain (our unit of parallelism) collect its…
We recently published a paper on concurrent system programming with effect handlers . In this paper, we show that with the help of effect handlers, we could express in direct-style , various interactions of a concurrent program with OS services that typically require callbacks. The question is what do we do about legacy code that uses monadic concurrency libraries such as Lwt and Async. Surely a…
One of the key indicators of maturity of a language ecosystem is the ease of building, managing and publishing software packages in that language. OCaml platform has made steady progress in the last few years to this end. While OPAM simplified package (and compiler) management, the developing and publishing packages remained a constant pain point. This situation has remarkably improved recently…
Ezirmin is an easy interface over the Irmin , a library database for building persistent mergeable data structures based on the principles of Git. In this post, I will primarily discuss the Ezirmin library, but also discuss some of the finer technical details of mergeable data types implemented over Irmin. Contents Contents Irmin and Ezirmin Quick tour of Ezirmin Merge semantics Working with…
Behavioural types such as session types, contracts and choreography describe the behaviour of a software entity as a sequence of operations on a resource such as a communication channel, web service session or a file descriptor. Behavioural types capture well-defined interactions, which are enforced statically with the help of type system machinery. In this post, I will describe a lightweight…
Efficient concurrent programming libraries are essential for taking advantage of fine-grained parallelism on multicore hardware. In this post, I will introduce reagents , a composable, lock-free concurrency library for expressing fine-grained parallel programs on Multicore OCaml . Reagents offer a high-level DSL for experts to specify efficient concurrency libraries, but also allows the consumers…
This is a short tutorial on how to build Reason apps for an ARM target with the help of Docker. I am using Docker for Mac , which is still under beta program. Using Docker for development has two important advantages over traditional cross-compilation. First, the Reason toolchain comes packaged as a Docker image and hence no local installation is necessary. Secondly, cross-compilers are often…
In the last post , I described a flat allocation profiler for OCaml 4.02 bytecode interpreter. In this post, I’ll describe further developments which add support for call stack information and better location information. Lets dive straight to the usage: Enabling stack profiling Stack profiling is enabled by setting the environment variable CAML_PROFILE_STACK to the intended depth of stack.…
This post describes a simple flat allocation profiler for OCaml 4.02 bytecode interpreter. OCaml is a strongly typed functional language with automatic memory management. Automatic memory management alleviates the need to manually deal with memory memory management, and by construction, avoids a large class of bugs. However, abstractions are not free in OCaml. Unlike MLton , a whole-program…
I recently gave a talk on Algebraic Effects in OCaml at the OCaml Workshop 2015 . The extended abstract and the slides from the talk are available here . The slides should provide a gentle introduction to programming with algebraic effects and handlers in OCaml. The examples from the talk (and many more!) are available here . Algebraic effects in OCaml are available as a part of the multicore…
In the previous post , I presented a simple cooperative multithreaded scheduler written using algebraic effects and their handlers. Algebraic effects are of course useful for expressing other forms of effectful computations. In this post, I will present a series of simple examples to illustrate the utility of algebraic effects and handlers in OCaml. Some of the examples presented here were…
Algebraic effects and handlers provide a modular abstraction for expressing effectful computation, allowing the programmer to separate the expression of an effectful computation from its implementation. In this post, I will present an extension to OCaml for programming with linear algebraic effects, and demonstrate its use in expressing concurrency primitives for multicore OCaml . The design and…
OPAM has a great compiler switch feature that lets you simultaneously host several OCaml installations, each with its own compiler version and a set of installed packages. I wanted to use the power of opam switch for working with the experimental multicore OCaml compiler. The key advantage of doing this is that it lets you easily install packages from the OPAM repository , while sandboxing it from…