TypeScript

Why not using Reason ML?

ReasonML promised a better JavaScript: static types, fast compilation, functional programming, and Facebook's backing. It compiles to JavaScript via Buckl...

14 Oct 2023

Why not using Reason ML?

ReasonML promised a better JavaScript: static types, fast compilation, functional programming, and Facebook's backing. It compiles to JavaScript via BuckleScript, and it's built on OCaml — a language researchers have refined for over 20 years.

On paper, it's impressive. In practice, adoption never took off.

What ReasonML actually is

Take JavaScript's syntax, add OCaml's type system and functional programming model, and compile back to JavaScript. That's ReasonML. It feels like a cleaned-up JavaScript with strong types and pattern matching.

It sits on top of OCaml, which brings:

  • A powerful type system with inference
  • Pattern matching and algebraic data types
  • Automatic memory management
  • Efficient native code compilation

1_u4eIdf2l2gTXS3r13i_YHg.webp

Integration into existing projects

ReasonML compiles to CommonJS modules. That means you can adopt it incrementally — replace one module at a time without rewriting your entire codebase.

The tooling support was reasonable: npm for packages, webpack for bundling, Elm-style error messages, and editor plugins for VS Code, Vim, and Atom. Facebook even built React bindings for it.

ReasonML vs Elm

I wrote about Elm separately, but here's the quick comparison:

  • ReasonML had Facebook's backing. Elm was community-driven.
  • ReasonML compiled faster.
  • ReasonML was simpler but less safe — it wasn't purely functional.
  • ReasonML had DOM access. Elm deliberately didn't.
  • ReasonML worked on the server. Elm was browser-only.

Why it didn't win

The learning curve. It's steep at first. OCaml concepts take time. Teams already stretched thin on JavaScript don't have bandwidth to learn a new paradigm.

The community. Fewer than 200 questions on Stack Overflow. Google Trends showed minimal search interest. When you hit a problem, you were often on your own.

1_MnYHeQ_Y6fVGX-4wIDCQPg.webp

The trade-off

ReasonML offered real technical advantages: sound type system, fast builds, functional purity where you want it. For small projects or isolated modules, it worked well.

The cost: no community means no ecosystem. No ecosystem means solving problems alone. TypeScript won this battle by being "just JavaScript with types" — a much smaller leap for teams to make.

Knowing what a language does well and where it falls short is more valuable than picking a side. ReasonML taught me that the best technology doesn't always win. Adoption does.