Confused about ReScript? ReScript, Reason, ReasonML, and BuckleScript explained

  • If you’re a web dev and you’ve heard about this newfangled ReScript/Reason/ReasonML/BuckleScript thingy, you’re most likely looking for ReScript, which is a new language that combines the best parts of JS and OCaml. It has a compiler that compiles to JS and leverages OCaml’s static and sound type system. Many people prefer this approach to TypeScript. It also has an awesome and growing community with people who are ready to help you learn the language.
  • ReScript grew out of Reason (a JS-like syntax for OCaml), BuckleScript (the former name of the ReScript compiler and toolchain) and ReasonML (the name for the ecosystem that grew up around Reason’s syntax). Reason and ReasonML still exist whereas BuckleScript morphed into ReScript, introducing with it a new Reason-like syntax and a new community.
  • If you’ve been confused by the ReScript team’s announcement that Reason “rebranded” into ReScript, you’re not alone. What it boils down to is that ReScript is a new, distinct language with historical links to Reason that will diminish over time as the language grows.

Reason

ReasonML

According to Jordan Walke:

BuckleScript

ReScript

ReScript is a language that combines the best parts of JS with the best parts of OCaml. It has its own syntax, compiler, formatter and build tools. It also has a vibrant community that’s interested in making OCaml’s power and its sound, static typing as accessible to JS developers as possible.

Can you see the connection to Reason, BuckleScript and ReasonML? ReScript combines all three into a fully-fledged language:

  • A JS-like syntax for OCaml (like Reason)
  • A compiler and toolchain (like BuckleScript)
  • A community and various tooling (like ReasonML)

“Rebranding” BuckleScript as ReScript

In August 2020, the BuckleScript developers announced that they were “rebranding” their compiler as ReScript, which was already the name of their new Reason-like syntax. Their intention was to signal that web development efforts in the ReasonML world around Reason and BuckleScript would henceforth go under a single banner, “ReScript.” The hope was that, whatever short-term pain might stem from changing the name, in the long term having a single brand would help boost adoption. I believe that this prediction will eventually pan out.

  • Independence from OCaml: Remember Jordan Walke’s description of ReasonML as a way of bringing OCaml to “the widest number of developers, and today that means JavaScript developers”? BuckleScript’s devs wanted to give themselves the freedom to break away from OCaml’s idioms and even its features. For example, ReScript has introduced the uncurried calling convention to make JS interop better, and the team plans to remove support for OCaml classes and objects from the compiler. Whereas BuckleScript could be thought of as an OCaml compiler, ReScript’s compiler is really intended to be a compiler for its own language.
  • Closer to JS: ReScript’s syntax has gone beyond Reason to adopt idioms from the JS ecosystem. For example, replacing the parens surrounding Reason type parameters with angle brackets, as in array<string> instead of array(string), resembles generic types in TypeScript.
  • Relegation of Reason to legacy status: The rebranding announcement effectively froze the ReScript compiler’s support for Reason syntax. Existing Reason code will work for a long time, but changes to Reason will not be supported by ReScript and vice versa. The ReScript team’s focus will now be on their own syntax.
  • Parser: The team wrote a new parser compatible with ReScript, Reason and standard OCaml syntaxes. The old Reason parser still exists in a separate repo, maintained by the Reason team.
  • New website and documentation: A new, rebranded site was launched with a guide focused on ReScript syntax, unlike the old BuckleScript site which offered examples in Reason and OCaml. Although the documentation dropped references to the old syntaxes, the ReScript compiler still supports them.
  • Community: A new forum, Twitter account, and Discord channel were launched.
  • Emphasis on ReScript as a language: If you look through the documentation, blog posts and all the community resources, you’ll notice that the team appears to emphasize that ReScript is a language, not a syntax. There’s been a concerted effort to think of ReScript as its own thing rather than just an extension of OCaml, even more so than has been the case with Reason.
  • Governance: Reason is maintained by Facebook whereas ReScript, having been driven by BuckleScript’s team, is largely community-driven.

Where does that leave us?

What does all this mean for those of you who are looking to use Reason or ReScript in your projects? It’s simple:

  • ReScript’s own syntax (which is derived from Reason’s syntax; this is what you should be using for new projects)
  • OCaml’s Reason syntax (i.e., plain ol’ Reason; specifically, the version from around August 2020 when ReScript split off, which as of writing is still very similar to ReScript’s syntax)
  • ReScript-specific features (e.g., the uncurried calling convention for JS interop; there aren’t too many of these features as of writing)
  • OCaml features (because ReScript started as a Reason-like syntax for OCaml that was supported by BuckleScript)
  • BuckleScript-specific libraries that carried over into ReScript (e.g., Belt, Js)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store