Lesson 8 of 9 · 21m
ReasonML, ReScript, and the JavaScript Split
Understand what ReasonML was, how ReScript diverged, and what interoperability realistically means for teams targeting JavaScript today.
The most important fact about ReasonML is historical, and skipping it creates bad architecture decisions. Reason began as a syntax and toolchain layer intended to make OCaml more approachable to JavaScript developers. Then the ecosystem split: native OCaml continued evolving, while the JavaScript-focused path became ReScript with its own compiler, tooling, and priorities. Treating them as one interchangeable thing in 2026 will hurt you.
Reason syntax is not a different type system
Historically, Reason syntax parsed to the same underlying OCaml representation. You could write:
let add = (x, y) => x + y;
type payment =
| Draft
| Authorized(string)
| Captured(string, string);and compile through the OCaml ecosystem. The semantics came from OCaml: inference, variants, modules, and pattern matching. Syntax changed; the ML core did not.
ReScript made different tradeoffs
ReScript optimized hard for JavaScript output, fast compilation, straightforward interop, and a language surface tailored to web application development. That means it is not simply 'OCaml but prettier.' Parts of OCaml's module power, runtime model, and native ecosystem do not transfer directly.
If your target is server-side native OCaml, choose OCaml tooling. If your target is JavaScript with ReScript, evaluate ReScript as its own language ecosystem.
JavaScript interop is boundary engineering
Interop declarations are where type safety meets an untyped host. A binding is a claim you are making about JavaScript reality:
@module("crypto")
external randomUUID: unit => string = "randomUUID"That claim may be wrong. The compiler trusts your external declaration. Validate at the boundary, keep bindings thin, and avoid exposing raw JavaScript objects deep into typed application code.
Null, undefined, and option are not interchangeable
JavaScript APIs routinely distinguish null, undefined, missing object properties, and empty strings. ReScript models absence with options and explicit interop representations depending on the binding. Sloppy conversion here is a classic production bug: the type checker approved a lie written in the external declaration.
Why teams still cared
Reason's enduring lesson is ergonomic: ML semantics can be taught to mainstream teams if syntax, formatting, editor integration, and error messages respect them. ReScript's generated JavaScript can be compact and fast because the compiler knows more than a generic transpiler. But ecosystem fit beats ideology. If your team needs npm libraries every hour, a highly principled boundary can still become expensive friction.
A sane evaluation checklist
target runtime: native, browser, Node, edge worker?
library ecosystem: opam or npm?
concurrency model: OCaml runtime or JavaScript event loop?
data boundary: JSON validation strategy?
build owner: who understands compiler upgrades?
debugging story: source maps, stack traces, production symbols?Answer those before choosing a dialect because the migration cost is not just syntax conversion.
Field notes
- Do not assume
.refiles, ReScript.resfiles, and OCaml.mlfiles interoperate freely in one project; their toolchains and versions matter. - ReScript external declarations are unchecked contracts with JavaScript. Review them like FFI code.
- Automatic JSON encoders help, but versioning and malformed input still require explicit validation decisions.
- ReasonML examples from older blog posts often reference BuckleScript-era behavior that no longer matches modern ReScript.
Was this lesson helpful?