[ANN] Melange 3.0

Dear OCaml users,

the Melange team is proud to announce the release of Melange 3.0.

Melange is a backend for the OCaml compiler that emits JavaScript. This release focuses on:

  • Improved OCaml version support: we’re releasing Melange v3 with full support for OCaml 4.14 and OCaml 5.1, similar to Merlin’s recent versioning scheme (3.0.0-414 and 3.0.0-51).
  • Better JavaScript interop: we support more combinations in our Foreign Function Interface layer, allowing to output more JavaScript constructs without resorting to %mel.raw
  • Made Melange leaner and more robust:
    • in the compiler core, we fixed a few crashes, removed unused code and made other code faster;
    • in the Melange runtime libraries, we unified APIs that were duplicated or inconsistent
  • Implemented more runtime primitives and enabled additional Stdlib functions

With the release of Melange 3, we’re also introducing a redesign of our documentation website. We added an overall new design, snappier navigation and real-time search.

I wrote a more comprehensive release announcement in the following post:

As always, feedback is very much appreciated.

This release of Melange is sponsored by Ahrefs and the OCaml Software Foundation .


Nicely done :star_struck:

It’d be nice if the project could offer little examples demonstrating different use cases for melange.

For instance, I’m not interested in reactjs or any frontend integration at all, but I’m working on a typescript web backend at work (running on expressjs) and I’d like to evaluate how I could convince my colleagues to replace chunks of it with OCaml/melange.

It looks like it’s possible

1 Like

Hi, thanks for your interest.

It should be possible to replace parts of a NodeJS application with Melange. We created a repository that includes some variety of examples with the purpose of allowing folks to see different use cases or configurations:

These examples include a simple Node example. New additions are of course welcome.

Regarding bindings to Node, currently Melange offers some (limited) bindings to the most common functionality, which are documented in the project site in both Reason syntax and OCaml syntax. It should be fairly straightforward to port more extensive bindings like rescript-nodejs to Melange, but I haven’t tried.

Another approach could be to replace parts of the NodeJS application with an OCaml native server using Dream or something else. This approach will have a few advantages like better performance, more libraries directly available without the need to write bindings, and more examples available. But it is also a larger gap to cross if the team is not familiar with OCaml.

If you experiment or try to build something and run into issues, feel free to reach out either here or in the Reason discord server :slight_smile:


Thanks for your feedback, good to know about the examples repo, I missed it and even though it’s doesn’t have much at the moment it should be useful for future reference.

Good suggestion about the rescript-nodejs project, I could use it as a kind of reference, at least to get a feel for things.

Very nice job, thank you! This is a big step for all those who want to write for the Javascript platform first, but still seek for maximal compatibility with the Ocaml platform.

Two questions (requests):

  • in a lot of modern Javascript await/async comes up. I know Ocaml has some
    features to deal with it without having to fall back into nested callbacks. Could you please write a small something on that subject?

  • also from a newcomer perspective: The 4 options to choose from when looking for help is not 100% ideal. maybe you could some info when to choose which channel (Community | Melange Documentation Site)

Thanks again for the great work on Melange