What is actually going on now with ReasonML and ReScript?

When I first wrote this post, I had remembered that BuckleScript was briefly renamed “ReasonScript” before becoming “ReScript”. My memory appears to have been in error on this point, and I have marked the mistakes with strikethrough text.

It is possible that the OCaml community is not the right place to ask about what is going on with these prodigal-child languages, but I figure maybe someone who knows about still hangs out here.

Here’s what I know:

  • Bloomberg makes a JS backend for the OCaml compiler called BuckleScript.
  • Facebook, wants to add curly brackets to OCaml, so they write a new compiler frontend. They call this “Reason”, which I can only imagine is an ironic name, given that there is absolutely no reason to do it.
  • These two things get joined together somehow, but it is also possible to use them independently.
  • The ReasonML (formerly Reason) people allegedly stop caring about browser usecase (according to the BuckleScript people).—I very much have my doubts about this point in retrospect, and I wonder if the issue wasn’t more that the Reason people were not interested in bastardizing OCaml any further in the name of JS compat. Seems like they are still interested in supporting the browser usecase.
  • as a result, the BuckleScript people fork the frontend, taking the name ReasonScript ReScript and has the “vision” of making further changes to OCaml semantics to be more friendly to the browser.
  • At this point ReasonScript ReScript more or less abandons OCaml compatibility as a goal and BuckleScript is pretty much dead.
  • In a great stroke of madness, ReasonScript changes it’s name to “ReScript”, and I can only think about old Pepe memes when I see the name.
    image
    REEEEE

So that’s great.

ReScript is now completely separate from OCaml, but it seems to be thriving, more or less.

I had the impression ReasonML was dying, that the ReScript schism was sort of the final nail in its coffin, because the community appears to be so inactive, but they are still doing releases and I see now that they have a different JS backend for OCaml, Melange, which seems positive.

So, is ReasonML still a thing? And this Melange? Is this now a reasonable way to compile regular OCaml to JavaScript? Are we still better off sticking to Jsoo, or do we once again have multiple ways to approach JS as OCaml programmers with no desire for curly braces?

5 Likes

Not sure if meant to be tongue-in-cheek or AI-generated or what. ReScript and Reason are both doing fine. There are different tools with different names in both those ecosystems, same as you have both opam and dune in OCaml and outsiders can make fun of it and say ‘lul they need two build tools just to run a project’. Obviously we know that’s not true and that the tools are specialized to do certain tasks. Same thing with Reason/Melange/etc.

I think the most productive way to go forward is to ask what are your requirements. If you are looking for something that you can introduce to a dev team as a plausible alternative to TypeScript, then try ReScript. If you are looking for very mature OCaml ecosystem compatibility when compiling to JS, try JSOO (optionally with Reason syntax). If you are looking for something in the middle, try Melange (again optionally with Reason syntax).

4 Likes

It’s definitely not AI generated! (just what the AI would say, right?)

I guess it’s mostly tongue in cheek, but the tone is probably also a result of two things:

  • My complete failure to understand the motivation to transform a beautiful language like OCaml into something like more like JavaScript—as if being like JavaScript is a good thing.
  • My frustration over trying to understand the different parts of the different projects, especially through multiple name changes in each—which I believe I finally have done.
    • Reason syntax became ReasonML when it started using the BuckleScript backend
    • BuckleScript wanted to double-down on JavaScript interop and stopped working with ReasonML because they wanted more radical sematic changes. It became ReasonScript
    • ReasonScript became ReScript, just 'cause. I find this an incredibly strange name.
    • ReasonML continues to exist under that name, but now it’s Reason syntax + Melange JS backend

You have to admit that understanding what happened with these projects is confusing through all the name changes.

I just want a way to use OCaml with React, and I’m trying to figure out if there is a sensible way to do that. I’m glad to hear that ReasonML is still going strong and the existence of Melange is great news for me. I’m definitely not upset about combining different frontends and backends. I find this part very cool.

I think the thing that made me really confused a bit salty was, at some point one of the ReScript (formerly BuckleScript) maintainers was on this very message board saying they broke away from ReasonML because the Reason people were no longer interested in supporting the JavaScript usecase, and I thought that was actually true, but it turned out just to be a justification for parting ways when the BuckleScript project decided it wanted to leave OCaml behind. Or, I don’t know. Maybe it was true for a while? It doesn’t appear to be true now. The Reason project still appears to care about the web usecase.

3 Likes

2 reasons to do it:

  • the #1 syntax error that confuses people that learn ocaml is let vs let/in. By removing the in construct and replacing with ;, it removes the most common error.
  • to manipulate markup, it is very useful to have first class syntax for JSX. Reason had that early on, in a way that was integrated with the formatter.
3 Likes

I can’t talk for rescript, as we aren’t using it much nowadays. But melange is very much being actively developed. And the main use case at ahrefs is to use ocaml with react. See Ahrefs is now built with Melange. OCaml, all the way down | by Javier Chávarri | Ahrefs

The same team developing melange also picked up the maintenance of the reason syntax. It is not moving very fast, I don’t expect the syntax to evolve much, but it’s being updated to work with recent ocaml versions. And some bugs are being fixed.

As before, you can use melange with whichever syntax you prefer. Ahrefs is using reason partially for legacy reasons and partially because it’s still the syntax with the best jsx support. But if you wish to use jsx without curly braces you might have a look at GitHub - andreypopp/mlx: OCaml syntax dialect which adds JSX syntax expressions.

If you want to use jsoo then you probably will be interested by GitHub - ml-in-barcelona/jsoo-react: js_of_ocaml bindings for ReactJS. Based on ReasonReact..

8 Likes

I’m looking for this too, using Dream in the backend, hopefully. The Dream repo has a couple of examples on how to bundle it with Reason and ReScript.

1 Like
  • I greatly prefer the F# approach to fixing let/in, but I suppose that’s subjective. Moreover let/in could reasonably be called a wart on OCaml syntax, but this alone is not a reason to fork the syntax, in my opinion.
  • There’s no technical reason why JSX support requires OCaml to look more like JavaScript. Not even JavaScript itself has JSX built in, so these are unrelated issues.
    JSX is a good reason to use Reason, but it’s not an argument for Reason’s departure from OCaml syntax.

I guess my overall issue is that I just want to write OCaml with some of the benefits that BuckleScript had over Jsoo, and I was given the impression that this option “went away” when BuckleScript became ReScript, but it appears Melange is filling that gap now.

So I am happy.

2 Likes

I think this is key here, do you want to understand the current state of the world or the messy history that led to it…

The way I see things:

  • ReScript is in the tradition of CoffeeScript and Typescript, it provides an alternative language to people who wish to write a better Javascript. Its ecosystem is centered around npm, and aside from its historical roots, it has little to no links to OCaml.

  • ReasonML is an alternative syntax to OCaml, the same way the revised syntax is/used to be. The Javascript story is (mostly) orthogonal to it, ReasonML is a valid choice for pure backend, compile to native, projects. Where it ties strongly to JS is its JSX syntax that allows you to write react applications with a nice integration.

  • Melange aims to be the best compile to JS tool of the OCaml ecosystem, spiritually it picks up where bucklescript stopped (even if technically it was forked from rescript I think). It shines if your goal is to write OCaml front to back, and the competitor in that category is eliom.

Presented that way, you have 3 very different projects with different aims.
It explains why ReasonML is not push changes aggressively (how often do you want your syntax to change?).
And we don’t need to scare people with all that messy history. :slight_smile:

13 Likes

I can def. understand the confusion as the last blog post about ReasonML is from 5 years ago which makes it seem dead. However, if you look at the git history you can see that there is still very much action happening!

Personally I also prefer the ocaml syntax but I can imagine that introducing ReasonML would be more palatable to a team that has only used js/ts.

1 Like

The reason why I had speculated that it might be AI-generated was that there were just some incorrect claims in the OP. And in fact the incorrect claims are being repeated. For example, there was never anything called ‘ReasonScript’. The ReScript team announced the name and project change in a clean break from the Reason project, and people parted ways to work on the things they found interesting.

Reason people wanted to keep full compatibility with the OCaml ecosystem and ReScript people wanted to focus on building a really great AltJS language with first-class React support, based on OCaml. And I think both the teams have done what they aimed to.

1 Like

Another adjacent option I often find myself mentioning is to use tyxml’s JSX ppx, which allows you to use JSX in .re files (and IME pretty minimal actual reason code, if you’re judicious with how you organize things) to describe frontend stuffs separate from everything else that can continue to live in regular OCaml.

1 Like

I think you must be right about “ReasonScript” never exiting. I have a very distinct memory of this name, but I can’t find any evidence of it, and it wouldn’t be the first time my memory has made stuff up. I’ll edit my original post to reflect this error.

Reason people wanted to keep full compatibility with the OCaml ecosystem

Also “full compatibility” might be in quotation marks here, since a lot of the OCaml ecosystem doesn’t work with Reason’s JS backend (Malenge) but does work with Jsoo. What Reason does do is keep semantic compatibility with OCaml so at least Reason’s native backed is indeed fully compatible with OCaml, making it possible to write a backend and frontend components which share a common set of compatible type definitions and utility functions, which is already a big win.

ReScript can’t do this with native compilation, but of course it will happily run on Node if you want to use it on the backend.

1 Like