ReScript and the future of ReasonML


#1

Hey folks. I’m a newbie to the Reason world, and I’ve just start dabbling in creating a React app using Reason/ReScript. I was enjoying that experience of learning the language and writing the app initially, however I have some concerns about the ecosystem and the direction the language is heading in. I was wondering if some veterans could comment on this… Specifically the split between ReasonML and ReScript.

There’s a lot of information out there that says that Reason is the language, and ReScript is simply a compiler. However that seems not to be the case any more, since ReScript decided to go its own way. ReScript now seems to be a fork of Reason, introducing its own distinct syntax and design decisions. Or - to put it another way - it’s yet another dialect of OCaml.

This raises a few alarm bells for me:

  1. It’s concerning that a language this young has already splintered. It’s not clear to me why these were separate projects in the first place. And when/why/how would someone ever use ReasonML itself, rather than ReScript?

  2. The primary motivation for the changes in ReScript seems to be to make it more JS-like. But given that ReasonML was intended to be an elegant alternative for those who were becoming dissatisfied with JS, this goal seems like a step in the wrong direction

Am I correct in my understanding of the relationship between these two projects? And are my concerns misplaced?


#2

I agree with both your concerns and while I’m not an authority, I can clarify a few points from my point of view as a BuckleScript user until experts chime in:

  • BuckleScript, as ReScript was initially called, started first, being an OCaml-to-JavaScript compiler which, unlike the existing Js_of_ocaml, produced highly legible and fairly compact JS output. It is a fork of the OCaml compiler, which is why it’s typically a few versions behind. (Not an issue in practice, for me.) This was internal at Bloomberg and eventually became open source when it matured.

  • ReasonML was a subsequent effort by Facebook to iron out what they perceived as inconsistencies in the OCaml syntax as well as provide something more familiar to JavaScript developers to help get more people interested. ReasonML is an alternate syntax which plugs into the stock OCaml compiler, and as a side effect of that, it can work with up-to-date native builds and the BuckleScript fork which targets JS.

  • Recently, the folks behind BuckleScript chose to rebrand into ReScript and propose their own syntax, but the compiler remained the same and “for the forseeable future” still supports OCaml syntax as well since it is just a fork of it, at least for now. I can only speculate that ReScript may have been because of dissatisfaction with some choices made by ReasonML. So now we have 3 syntaxes to choose from. I personally see the ReScript syntax as experimental and the ecosystem as burgeoning, so I’m sticking with OCaml until either ReasonML or ReScript settles as a mature winner of the “gateway syntax from JS to ML” niche.

<rant>I wish these branding choices were more mindful of how they’re going to be used. Searching for “reason” or “rescript” on Google is not a pleasant experience. Thankfully there’s “ReasonML” which is distinct enough.</rant>


#3

If BuckleScript rebranded to ReScript, why did the Reasonml.org website get taken with it too?


#4

The ReasonML.org site was an effort to combine the documentation of ReasonML and BuckleScript, since the former depends on the latter when targeting browsers. The official sites for browser and native ReasonML continue to be https://reasonml.github.io/ and https://reason-native.com/


#5

Something that still confuses me is what the purpose of https://reasonml.github.io/ is, given that it instructs you to install bs-platform, and that large chunks of the documentation redirect you to the ReScript docs… Surely ReasonML should either stand as its own platform, or it should shut down in favour of ReScript


#6

I’m guessing forking bs-platform would require more effort than it’s worth vs using it as a simple dependency.


#7

ReasonML will continue as it’s own platform targeting native only, not the browser. bs-platform won’t be involved; the website just hasn’t been updated. The current state of the project is laid out in this github issue:


#8

Ah, now this clears things up. Thanks. I hope the documentation is updated soon, because I know a lot of people are pretty confused about all this too