OCaml Weekly News

Previous Week Up Next Week


Here is the latest OCaml Weekly News, for the week of December 05 to 12, 2023.

Table of Contents

Ecosystem Wishlist Survey

Sabine Schmaltz announced

Hey OCaml folks,

I am running a little OCaml Ecosystem Wishlist survey where you can put in really specific wishes for

  • new packages,
  • package improvements,
  • compiler / tooling / language changes

I’m really curious what you all need and I think this will be helpful to better understand the current state of the ecosystem.

The survey will stay open at least into January, probably much longer.

Put those wishes in! đŸŽ„đŸ«đŸ”„đŸ”„


OUPS meetup december 2023

zapashcanon announced

The next OUPS meetup will take place on Thursday, 14th of December 2023. It will start at 7pm at the 4 place Jussieu in Paris.

:warning: :trumpet: It will be in the in the Esclangon building (amphi TBA). :trumpet: :warning:

Please, register on meetup as soon as possible to let us know how many pizza we should order.

For more details, you may check the OUPS’ website .

This month will feature the following talks :

Miou, un simple scheduler pour OCaml 5 – Romain Calascibetta (@dinosaure)

Miou est un scheduler pour OCaml 5 utilisant les effets nouvellement introduit. Il se concentre sur la disponibilitĂ© d’une application au travers d’une politique de gestion des tĂąches bien dĂ©crite. Cette prĂ©sentation introduira les effets avec OCaml 5 ainsi qu’une rĂ©trospective de son API. Il s’agira ensuite de prĂ©senter les spĂ©cifitĂ©s de Miou par rapport aux autres schedulers. Enfin, il y aura la prĂ©sentation d’un client/serveur HTTP dĂ©veloppĂ© selon le design de Miou. La prĂ©sentation permettra de faire un Ă©tat des lieux du scheduling en OCaml, des raisons de la multiplicitĂ© des solutions ainsi que des objectifs concrets de Miou (implĂ©mentation de services, disponibilitĂ©s des applications, unikernels).

Towards a solution to the expression problem for compilers: strongly typed nano-passes – Boris Yakobowski

We present a new solution to the problem of (strongly) typing compiler passes when the source and destination language share multiple constructors. We are interested in approaches that limit the amount of boilerplate that needs to be (re)written for each language, while still maintaining a very strict typing discipline. Our solution uses well-known tools, but combine them in a novel way:

  • the idea of nanopasses, in which each pass encodes a very limited transformation
  • the use of ppx syntax extensions to express only the differences between a language and the next
  • the traversal of the AST using top-down and bottom-up recursion schemes
  • OCaml polymorphic variants, which are instrumental to precisely type our (non-recursive) transformation functions.

We present our implementation of this approach in the context of the Ada frontend for the Infer analyzer, which as of today contains 28 passes. We will also discuss the various pitfalls we have encountered along the way, as well as possible improvements (in particular deforesting the combination of multiple passes).

Js_of_ocaml 5.2

Hhugo announced

I’m pleased to announce the release of js_of_ocaml 5.2. It should soon be able available in opam.

Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. It makes it possible to run pure OCaml programs in JavaScript environment like browsers and Node.js.

Most significant changes:

  • Improve support for modern javascript
  • New global dead code elimination pass. Jsoo can now drop unused code inside functors. See the pull request for more details
  • Change strategy used for control flow compilation. It was adapted from wasm_of_ocaml and based on the following paper https://dl.acm.org/doi/abs/10.1145/3547621.

See the Changelog for other changes.

containers 3.13

Simon Cruanes announced

Hello, I just released containers 3.13 on opam.

This release is somewhat more breaking than usual:

  • OCaml 4.08 is now the minimum OCaml version.
  • CCShims_ (which was used to provide a shim for Stdlib pre-4.08) is removed
  • containers-thread, which was deprecated, is no more. The recommended alternative is Moonpool.

On OCaml 5.1 and above, tail-rec-mod-cons is used to simplify and accelerate some functions in CCList.

Happy hacking!

Melange 2.0

Antonio Nuno Monteiro announced

Melange 2.2 is now out with support for OCaml 5.1.1.

OCaml 5.1.1 released

octachron announced

In the last three months after the release of OCaml 5.1.0, three significant regressions have been discovered in OCaml 5.1.0. Those regressions concern the packaging of executables, the typechecking of OCaml programs, and the performance of numerical codes.

Since those regressions affect many users and could have lasting effects, we have published a patch release, OCaml 5.1.1, fixing those issues.

As a major exception to our policy for patch releases, OCaml 5.1.1 will contain one breaking change in the standard library: the Compression flag has been removed from the Marshal module. This drastic measure has been taken because supporting zstd compression in the standard library made zstd a dependency of all OCaml executables. Since the compiler should not propagate its dependencies on end-users, the support for compressed marshalling has been moved to a compiler internal library in 5.1.1.

Accounting for the still experimental nature of the multicore runtime, this patch release 5.1.1 also contains safe fixes for subtle concurrency bugs in the OCaml runtime.

In brief, if you were using OCaml 5.1.0, I strongly recommend that you switch to 5.1.1 .

The full list of changes is available below for more details.

Installation Instructions

The base compiler can be installed as an opam switch with the following commands:

opam update
opam switch create 5.1.1

The source code for the release is also directly available on:

Changes in OCaml 5.1.1 (8 December 2023)

  • Standard Library
    • (breaking change) #12562, #12734, #12783: Remove the Marshal.Compression flag to the Marshal.to_* functions introduced in 5.1 by #12006, as it cannot be implemented without risking to link -lzstd with all ocamlopt-generated executables. The compilers are still able to use ZSTD compression for compilation artefacts. (Xavier Leroy and David Allsopp, report by Kate Deplaix, review by NicolĂĄs Ojeda BĂ€r, Kate Deplaix, and Damien Doligez).
  • Bug Fixes
    • #12623, fix the computation of variance composition (Florian Angeletti, report by Vesa Karvonen, review by Gabriel Scherer)
    • #12581, #12609: Fix error on uses of packed modules outside their pack to correctly handle nested packs (Vincent Laviron, report by Javier ChĂĄvarri, review by Pierre Chambart)
    • #12645, #12649 fix error messages for cyclic type definitions in presence of the -short-paths flag. (Florian Angeletti, report by Vesa Karvonen, review by Gabriel Scherer)
    • #12757: Fix ocamlnat (native toplevel) by registering frametables correctly (Stephen Dolan, Nick Barnes and Mark Shinwell, review by Vincent Laviron and SĂ©bastien Hinderer)
    • #12791: extern is applied to definitions of caml_builtin_cprim and caml_names_of_builtin_cprim when linking bytecode ’-custom’ executables with a C++ linker. (Shayne Fletcher, review by Antonin DĂ©cimo and Xavier Leroy)
  • GC Performance Regression Fixes
    • #12318: GC: simplify the meaning of custom_minor_max_size: blocks with out-of-heap memory above this limit are now allocated directly in the major heap. (Damien Doligez, report by Stephen Dolan, review by Gabriel Scherer)
    • #12439: Finalize and collect dead custom blocks during minor collection (Damien Doligez, review by Xavier Leroy, Gabriel Scherer and KC Sivaramakrishnan)
    • #12590, #12595: Move caml_collect_gc_stats_sample in caml_empty_minor_heap_promote before barrier arrival. (B. Szilvasy, review by Gabriel Scherer)
    • #12491, #12493, #12500, #12754: Do not change GC pace when creating sub-arrays of bigarrays (Xavier Leroy, report by Ido Yariv, analysis by Gabriel Scherer, review by Gabriel Scherer and Fabrice Buoro)
  • Runtime Bug Fixes
    • #11800, #12707: fix an assertion race condition in install_backup_thread (Jan Midtgaard, review by Gabriel Scherer)
    • #12486, #12535: Fix delivery of unhandled effect exceptions on amd64 with –enable-frame-pointers (Miod Vallat, report by Jan Midtgaard, review by Gabriel Scherer)
    • #12712, #12742: fix an assertion boundary case in caml_reset_young_limit (Jan Midtgaard, review by Guillaume Munch-Maccagnoni)
    • #12713, #12715: disable common subexpression elimination for atomic loads (Gabriel Scherer and Vincent Laviron, review by Vincent Laviron, KC Sivaramakrishnan and Xavier Leroy, report by Vesa Karvonen and Carine Morel)

DkML 2.1.0 - Major changes

jbeckford announced

I’m pleased to announce a major overhaul of DkML in version 2.1.0.

Some of the major changes include:

  • winget install dkml is the recommended way to install.
  • Installation is now in stages. The first stage (winget install dkml) takes 5 minutes and lets the end-user do utop, ocamlc and ocamlrun (sufficient for learning). However, any command that need Visual Studio (ex. opam, dkml) will first:
    • guide you if you need Git and/or Visual Studio (winget does not support auto-installing dependencies like other sane package managers), and then
    • install the OCaml system compiler, the opam root and a playground global switch automatically on first run
  • Alpha support for macOS/Silicon and most modern distros of GNU/Linux
  • Has an accompanying video describing how to install and use DkML on Windows targeted to both learners and professionals. Includes Visual Studio Code and LSP:

Call for Participation: BOB 2024 (Berlin, March 15)

Michael Sperber announced

More info at https://bobkonf.de/2024/!

			       BOB 2024
	     “What happens if we simply use what’s best?”
		       March 15, 2024, Berlin

	    Program: https://bobkonf.de/2024/program.html
	  Registration: https://bobkonf.de/2024/registration.html

BOB conference is a place for developers, architects, and decision-makers
to explore technologies beyond the mainstream in software development
and to find the best tools available to software developers today. Our
goal is for all participants of BOB to return home with new insights
that enable them to improve their own software development

The program features 14 talks and 8 tutorials on current topics:


Talk subjects includes functional programming, property-based testing,
service API design, programming for spacecraft, accessibility,
hypermedia, business processes, software analytics, event-based
communication and zero-knowledge proofs.

BOB will feature tutorials on F#, Haskell, Lean, SwiftUI, Copilot, the
K Framework, functional domain modelling, and Liberating Structures.

Andreas Rossberg will give the keynote talk.

Registration is open - online tickets are all under 200€, and many
discount options are available, as are grants for members of groups
underrepresented in tech:


ocaml-protoc 3.0

Simon Cruanes announced

Dear camlidae,

I’m happy to announce the release of ocaml-protoc 3.0 (alongside the multiple runtime libraries: pbrt, pbrt_yojson, and the new pbrt_services). This is a majorly breaking release, I’m sorry for that (I do, however, believe it necessary) and recommend every user of ocaml-protoc add an upper bound < 3.0 to their current project and migrate when they have time.

First, a summary. ocaml-protoc is a self-contained compiler that turns protobuf IDL files (.proto files) into OCaml types, pretty-printers, and (de)serialization functions. The runtime library pbrt (“protobuf runtime”) contains support code for printers and binary (de)serialization; pbrt_yojson contains support code for JSON (de)serialization by way of yojson.

So what changed with ocaml-protoc 3.0? Many things.

For a start, from one .proto file we now generate one pair of .ml and .mli files instead of several pairs. This reduces the boilerplate in build systems and simplifies user code overall (one module per .proto file). A large internal refactor of ocaml-protoc was done prior to the integration of

The major new feature of ocaml-protoc 3.0 is the support for service declarations. These are essentially a way to describe RPC endpoints, next to the types used to interact with the endpoint (example; full generated code). This is typically what it used in systems such as gRPC. Now ocaml-protoc generates server and client stubs for each endpoint, that pack together the type definitions and the relevant (de)serializers; that code doesn’t presume anything about a concrete RPC system. I have in the works a simple Twirp OCaml library that relies on this generated code to provide services over HTTP 1.1; It is also possible to write RPC systems over ZMQ, websockets, etc. without changes to the generated code[^1].

[^1]: note that twirp doesn’t support stream RPC over HTTP 1.1. Other RPC systems can support these, e.g. gRPC does.

Another big-ish change is how the generated code looks like, at least when it comes to binary (de)serialization. ocaml-protoc 3.0 comes with significant speedups for encoding (up to twice the throughput; order of magnitude reduction in allocations in some cases [^2]) and some less impressive speedups for decoding. This is a combination of multiple changes:

  • use of a few C stubs to accelerate varint decoding/encoding;
  • encoding is done back-to-front, which allows the encoder to use a single slice internally[^3]. This is what required changes in the generated code in the first place;
  • encoding code now requires a lot fewer closures (passing arguments explicitly instead) which reduces allocations to almost nothing.

I haven’t recently benchmarked against other protobuf implementations in OCaml, but I’m reasonably confident that this is now the fastest one by a healthy margin.

There are also other improvements and bugfixes. I want to thank in particular @Konstantin_Olkhovski for some of these contributions and for very helpful discussions, and also @VPhantom for more discussions on the topic of performance.

[^2]: if the encoder type is reused, there’s almost no minor allocations, and no major allocations, to encode an existing value into the encoder’s buffer.

[^3]: because sub-messages use varint as their sizes, encoding front-to-back cannot be efficiently done in a single buffer, because it’s not clear how many bytes to reserve in front of a sub-message. With back-to-front that’s not an issue.

The changelog contains many more details.

Other OCaml News


If you happen to miss a CWN, you can send me a message and I’ll mail it to you, or go take a look at the archive or the RSS feed of the archives.

If you also wish to receive it every week by mail, you may subscribe to the caml-list.