Skip to content

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 · 2 min read

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.

Ehsan Gazar helps software engineers take LLM and agent systems from demo to production. He writes about building LLM systems that hold up in production: evals, tracing, RAG, agent architecture and cost control. He teaches the Senior to Staff AI Engineer cohort on Maven, where engineers learn to design and defend these systems.

Go further
Live cohort on Maven

Forward Deployed AI Engineering: From Customer Problem to Production Value

A live Maven cohort for engineers: 10 live 90-minute sessions taking one AI engagement from customer problem to production, ending with eight artefacts and a working slice in your own repo.

January cohort starts Tue 12 Jan 2027, Tue & Thu 6:30pm London. Enrolling now, 20 seats, $1,800.

View the live cohort

Keep reading