r/ocaml • • Dec 16 '22

OCaml 5.0.0 is out!

Thumbnail discuss.ocaml.org
159 Upvotes

r/ocaml • • Jan 10 '22

OCaml Multicore merged upstream

Thumbnail
github.com
146 Upvotes

r/ocaml • • Feb 12 '25

New book for learning programming with ocaml

120 Upvotes

Dear OCaml community,

A long time ago, Sylvain and I wrote a French book on learning programming with OCaml. Recently, the OCaml Software Foundation funded its translation to English. The book is available here:

Learn Programming with OCaml

Many thanks to Urmila for a translation of high quality.

The book is available as a PDF file, under the CC-BY-SA license. The source code for the various programs contained in the book are available for download, under the same license.

The book is structured in two parts. The first part is a tutorial-like introduction to OCaml through 14 small programs, covering many aspects of the language. The second part focuses on fundamental algorithmic concepts, with data structures and algorithms implemented in OCaml. This is also a nice way to learn a language!

The book does not cover all aspects of OCaml. It is ideally complemented by other books on OCaml.

Link to official announcement and the book:

https://discuss.ocaml.org/t/learn-programming-with-ocaml-new-book/16111


r/ocaml • • Jun 15 '22

OCaml 5.0.0, zeroth alpha release

109 Upvotes

Five months after the initial merge of the multicore branch into the mainline OCaml and three months after the release of OCaml 4.14.0, OCaml 5.0.0 is starting to take shape.

I am thus happy to announce an exceptional zeroth alpha release of OCaml 5.0.0 (see below for the installation instructions).

This alpha release is expected to be rougher than an usual alpha release, due to the full rewrite of the OCaml runtime. In particular, the bytecode debugger will only be available in the next alpha release. Similarly, there will be some changes to the internal C runtime API and to the files installed by the compiler package in the next alpha release.

Moreover, this zeroth alpha release is the occasion to remind everyone that OCaml 5.0 itself is expected to be a more experimental release than usual. Notably, the native compiler will only be available on the ARM64 and x86-64 architectures in this 5.0 release.

Nevertheless, this zeroth alpha version is already stable enough for fellow hackers eager to join us in our early bug hunting and opam ecosystem fixing fun, or to venture in the new era of parallelism and (experimental) effects.

You can follow the progresses in stabilising the opam ecosystem on

https://github.com/ocaml/opam-repository/issues/21526

A brief summary is that at least dune, merlin, ppxlib, utop, ocamlfind, and ocamlbuild work (potentially by using patches from the alpha opam repository).

If you find any bugs, please report them here:

https://github.com/ocaml/ocaml/issues

In particular, any sequential OCaml 4 library or program should be valid in OCaml 5 (except for deprecated modules and functions). Please don't hesitate to report any forward-compatibility bugs!

If you are interested by the ongoing list of bug fixes, the updated change log for OCaml 5.0.0 is available at:

https://github.com/ocaml/ocaml/blob/5.0/Changes

Happy hacking, Florian Angeletti for the OCaml team.

Installation instructions

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

opam update
opam switch create 5.0.0~alpha0

For previous version of opam, the switch creation command line is slightly more verbose:

opam update
opam switch create 5.0.0~alpha0 --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git

If you want to tweak the configuration of the compiler, you can switch to the option variant with:

opam update
opam switch create <switch_name> ocaml-variants.5.0.0~alpha0+options <option_list>

where <option_list> is a comma separated list of ocaml-option-* packages. For instance, for a flambda and no-flat-float-array switch:

opam switch create 5.0.0~alpha0+flambda+nffa ocaml-variants.5.0.0~alpha0+options ocaml-option-flambda ocaml-option-no-flat-float-array

The command line above is slightly more complicated for an opam version anterior to opam 2.1:

opam update
opam switch create <switch_name> --packages=ocaml-variants.5.0.0~alpha0+options,<option_list> --repositories=default,beta=git+https://github.com/ocaml/ocaml-beta-repository.git

In both cases, all available options can be listed with "opam search ocaml-option".

If you want to test this version, it is strongly advised to install the alpha opam repository

https://github.com/kit-ty-kate/opam-alpha-repository

with

opam repo add alpha git://github.com/kit-ty-kate/opam-alpha-repository.git

This alpha repository contains various fixes in the process of being upstreamed.

The source code for the alpha is also available at these addresses:

https://github.com/ocaml/ocaml/archive/5.0.0-alpha0.tar.gz https://caml.inria.fr/pub/distrib/ocaml-5.0/ocaml-5.0.0~alpha0.tar.gz


r/ocaml • • Dec 21 '21

OCaml Multicore submitted for merging

Thumbnail
github.com
107 Upvotes

r/ocaml • • Jul 15 '26

Shout out to Daniel Bünzli

105 Upvotes

Just wanna give a quick hats off to Daniel Bünzli for all his work with OCaml. He seems to have created a lot of really well designed, comprehensive libraries, tools and utilities for the OCaml community.

He's made a whole declarative vector graphics library, a fairly well polished Js_of_ocaml middleman, a unicode decoder, a slightly nicer alternative to TyXML, an API for interfacing with the QOI image compressor...the list goes on.

Just take a look at his stuff: https://erratique.ch/software

FYI: I am not associated or affiliated with this man in any way, I am just impressed and wanted to send some appreciation


r/ocaml • • Jun 19 '26

OCaml 5.5.0 released

103 Upvotes

r/ocaml • • Apr 29 '22

New OCaml Website

Thumbnail
ocaml.org
103 Upvotes

r/ocaml • • Oct 07 '21

The road to OCaml 5.0

100 Upvotes

With the convergence between the multicore and standard runtime across OCaml 4.10.0 to 4.13.0, the development of OCaml multicore has reached a point where further integration into OCaml's main branch requires fully committing to a switch to OCaml multicore.

The OCaml team has decided that the time has come for such a commitment. The new major version, OCaml 5, will be a multicore version of OCaml. Moreover, OCaml 4.14 will be the last minor release of the 4.x series of OCaml.

Multicore Minimum Viable Product

The first version of OCaml multicore, code-named OCaml 5.0, will be a Minimum Viable Product focused on:

  • x86-64

  • Linux, MacOS, Windows mingw-w64

  • Parallelism through Domains [1]

  • Concurrency through Effect Handlers [2] (without syntactic support and exposed as functions from the standard library)

Our plan is to integrate the multicore branch into the main branch during the next 6 months. Hopefully, OCaml 5.0 will then be released between March and April 2022.

Note that OCaml 5.0 focuses on minimal (solid) support for the multicore runtime system, and will not provide stable user-facing concurrency and parallelism libraries. There has been a lot of experimentation [3,4] in the last few years, and some work remains to offer long-term, user-facing concurrent and parallel programming abstractions. OCaml 5.0 will be a great time to start adding concurrency and parallelism to your OCaml programs, but the libraries will still be in flux.

Long term support for OCaml 4.14

While OCaml 5 is stabilising, we plan to extend the support period for OCaml 4.14 by publishing minor bugfix releases whenever needed. In particular, OCaml 4.14 will be supported until all tier-1 architectures and operating systems are available in OCaml 5, and OCaml 5 sequential performance is close enough to that of OCaml 4.

The sequential glaciation

To ensure that maintainers can concentrate on Multicore integration, and avoid any rebase work for the Multicore developers, the trunk branch will be feature-frozen starting from November 2021. All non-bugfix non-multicore contributions will be delayed to after the Multicore integration. We are calling this period the "sequential glaciation".

We understand that this may be frustrating for our contributors, and apologize for the delay in getting your nice work reviewed and merged into the codebase. We hope that the sequential glaciation will be a good opportunity to help with the Multicore integration, review and testing, and/or focus on non-core-compiler efforts and the rest of the OCaml ecosystem.

With this early feature-freeze, we also plan to release OCaml 4.14.0 in advance, between January and February 2022, reducing the concurrency between the OCaml 5.0 and OCaml 4.14.0 releases.

References

[1] "Retrofitting Parallelism onto OCaml", ICFP 2020, https://arxiv.org/abs/2004.11663

[2] "Retrofitting Concurrency onto OCaml", PLDI 2021, https://arxiv.org/abs/2104.00250

[3] Domainslib -- Parallel Programming over Multicore OCaml, https://github.com/ocaml-multicore/domainslib

[4] eio -- Effects-based Parallel IO for OCaml, https://github.com/ocaml-multicore/eio


r/ocaml • • Aug 19 '20

OCaml 4.11.0 released

89 Upvotes

We have the pleasure of announcing the release of OCaml version 4.11.0, dedicated to the memory of Blaise Pascal on the anniversary of his death.

Some of the highlights in this release are:

  • Statmemprof: a new statistical memory profiler

  • A new instrumented runtime that logs runtime statistics in a standard format

  • A native backend for the RISC-V architecture

  • Improved backtraces that refer to function names

  • Support for recursive and yet unboxed types

  • A quoted extension syntax for ppxs.

  • Many quality of life improvements

  • Many bug fixes.

The full changelog can be found here.


r/ocaml • • Apr 30 '26

OCaml appreciation post

88 Upvotes

OCaml is easily my favourite programming language, even if the community around it is fairly small.

It's not perfect, but it's one of the few languages I've used where everything just fits together. The type system, algebraic data types, and pattern matching all make structuring programs feel straightforward instead of awkward. You end up modelling things properly from the start, and that cuts out a lot of the runtime issues you'd normally expect.

Once you get used to that, it's hard to go back. Dealing with nulls or loosely defined data in other languages starts to feel a bit rough. OCaml pushes you to be explicit, and the end result is code you can actually trust. It feels like going from writing with a biro to writing with a fountain pen.

Unpopular opinion, but I actually like the ML-style syntax. It's different at first, but it's consistent, and after a while it just feels normal. Most of the resistance to it seems to come from people being used to C-style languages more than anything else. I get why it looks awkward, but I think inertia has more to do with that than people admit.

There are obvious trade-offs. If you're building something that leans heavily on existing libraries or needs to plug into a bigger ecosystem, languages like Go or JavaScript are just easier to justify. That's usually what I end up using for client-facing work.

Same with quick scripting. OCaml isn't something you just pick up and start throwing scripts together in, but I don't think that's really what it's for.

OCaml does show up in industry here and there. Jane Street is the well-known example, but overall it's still a niche option. I've had friends ask me to teach them, and while I'd like that, I usually point them toward Python instead. It's just more useful to them early on. Bigger ecosystem, more tutorials, more opportunities.

That said, none of that really changes how I feel about it. For my own projects, it's always the first thing I reach for. It's just a nice language to spend time in. The tooling does what it needs to do (most of the time), and writing OCaml still feels fresh in a way most languages don't anymore.

It'll probably stay niche for a while, and honestly, I wish that wasn't the case. I'd love to see a bigger ecosystem, more people using it, more things being built with it. It deserves that much.

But even as it is now, it's still the language I enjoy using the most. And that's enough to keep me coming back to it.


r/ocaml • • May 25 '21

Dream — a simple, yet feature-complete Web framework

Thumbnail
github.com
85 Upvotes

r/ocaml • • Sep 27 '22

My NeoVim setup for OCaml

Post image
80 Upvotes

r/ocaml • • Jun 30 '25

The Economist writes about ocaml …

79 Upvotes

r/ocaml • • Sep 13 '20

q: A re-implementation of jq in Reason Native/OCaml

76 Upvotes

I re-implemented jq in Reason Native and OCaml and I'm a little proud 🌟 started as a way to learn how to write lexers/parsers/compilers with the OCaml stack, but ending up very functional.

I'm using it right now, every day. It's called query-json or for short "q".

https://github.com/davesnx/query-json

It has better performance (between 2x and 5x) than jq, richer error messages and simplified API. It’s mostly thanks to OCaml/Reason, rather than my skill to code a compiler! Still isn’t feature complete, though, but have implemented most of the common functionality, Adding those features shouldn’t affect the performance, so I will keep adding them with time.

You can check the benchmarks here: https://github.com/davesnx/query-json#Performance and the report: https://github.com/davesnx/query-json/blob/master/benchmarks/report.md

The main idea is to improve the api of the operations and errors with manipulation JSON files.

If you don't know what jq is, check https://thoughtbot.com/blog/jq-is-sed-for-json or https://programminghistorian.org/en/lessons/json-and-jq.

Hope you like it and let me know if there's something that you struggled with jq and I can make it better in q, let me know, I'm always open to any DM.

Thanks 👋🏽

PS: The creator of jq, which is a current OCaml core maintainer is doing ocaml-multicore, which at some point could improve the "q" performance even more.


r/ocaml • • Aug 27 '19

Major first step for OCaml Multicore merged to OCaml trunk

Thumbnail
github.com
76 Upvotes

r/ocaml • • May 17 '16

Reason: a new syntax and editor for OCaml, by Facebook

Thumbnail facebook.github.io
74 Upvotes

r/ocaml • • Mar 02 '21

I started working on an iOS app to learn and execute OCaml code from the device. After a lot of experiments, I start to have something working, I hope to be able to release it soon

Post image
73 Upvotes

r/ocaml • • Nov 03 '20

Leaving OCaml

Thumbnail
blog.darklang.com
73 Upvotes

r/ocaml • • Apr 04 '17

tracking multicore progress

72 Upvotes

To avoid repetitive posts asking whether multicore is arriving tomorrow, followed every time by a new flamewar, this post will track advancement of multicore OCaml (significant PRs, annoucements, merges, etc.). New posts that do not add anything to the subject and just rant about the lack of multicore will likely be removed.

list of PRs flagged as required for multicore support

update on 2022-03-09

  • it is done! Multicore was merged into trunk a little while ago and will be part of OCaml 5.

update on 2018-05-10

update on 2018-02-21

update on 2017-09-19

update on 2017-07-06

status on 2017-04-05

Previous efforts

Some links to previous posts that might be relevant:


r/ocaml • • Mar 30 '20

Multicore OCaml: March 2020 update

Thumbnail
discuss.ocaml.org
70 Upvotes

r/ocaml • • 26d ago

Spindle: an Eio-native web framework for OCaml 5

Post image
69 Upvotes

Hi r/ocaml!

I'd like to introduce Spindle, the web framework we've built in-house for our clients' backends. It's one of the core components of the Hypha Stack ecosystem, but can be used on its own.

  • RFC-strict and ergonomic, on its own HTTP/1.1 engine

  • Eio-native: straight-line handlers, multicore by design

  • Typed end to end: JSON derived from your types, every input validated

  • Interactive OpenAPI docs via Scalar at /docs, generated from your routes

  • Front end in sync: Zod or Melange schemas derived from your OCaml types

  • Batteries included: Postgres, WebSockets, SSE, sessions, logging, traces and metrics

👉 Docs: https://hyphatech.github.io/spindle/


r/ocaml • • Jun 24 '22

OCaml Programming: Correct and Efficient and Beautiful

Thumbnail
cs3110.github.io
69 Upvotes

r/ocaml • • Jul 29 '21

Cornell CS 3110 on youtube! Happy learning!

Thumbnail
youtube.com
69 Upvotes