Reason (programming language)

Last updated

Reason
Reason-logo.svg
Paradigms Multi-paradigm: functional, imperative, modular, object-oriented
Family ML: Caml: OCaml
Designed by Jordan Walke
First appearedMay 16, 2016;9 years ago (2016-05-16) [1]
Stable release
3.17.2 [2]   OOjs UI icon edit-ltr-progressive.svg / November 30, 2025;35 days ago (November 30, 2025)
License MIT
Filename extensions .re, .rei
Website reasonml.github.io
Influenced by
OCaml, JavaScript

Reason, also known as ReasonML, is a programming language and toolchain that is part of the OCaml programming language ecosystem. Reason uses many syntax elements from JavaScript, compiles to native code using OCaml's compiler toolchain, and can compile to JavaScript using the Melange compiler. [3]

Contents

Language characteristics

Since Reason is an alternate syntax to OCaml, they share the same characteristics. Both languages are general-purpose, [4] functional and object-oriented. [5]

While Reason compiles down to native code via OCaml's toolchain, it specifically differs in its syntax, error messaging, and editor tooling. This allows Reason to provide an experience more similar to JavaScript or TypeScript for developers.

Reason’s syntax is more similar to JavaScript and other C-style languages than to OCaml. For example, Reason tends to use curly braces to delimit blocks [6] and semicolons for separating statements, [7] while OCaml primarily uses parentheses or begin/end keywords to delimit blocks [8] , with nothing separating declarations. Reason also defines functions via an arrow-like syntax (rather than OCaml's fun keyword), [6] and calling a function requires parentheses around its arguments. [9] Other notable differences include naming the pattern matching keyword switch (instead of match), [10] and reformatting error messages to be more familiar to JavaScript programmers. [11]

The Reason community officially provides ReasonReact as a solution for web applications based on the React framework. [12] [13]

Example

typeschoolPerson=Teacher|Director|Student(string);letgreeting=person=>switch(person){|Teacher=>"Hey Professor!"|Director=>"Hello Director."|Student("Richard")=>"Still here Ricky?"|Student(anyOtherName)=>"Hey, "++anyOtherName++"."};

History

Jordan Walke, creator of the React web framework, first released Reason in 2016 while employed at Facebook. [1] [14] [15]

In the same year, Bloomberg L.P. introduced BuckleScript, a compiler which compiled OCaml to JavaScript. [16] As both projects were influenced by JavaScript, Reason and BuckleScript soon became an integrated toolchain, allowing Reason to target JavaScript. [17] [18]

However, the Reason team and the BuckleScript team had different priorities. The Reason team wanted to maintain compatibility with the OCaml ecosystem, while the BuckleScript team wanted to be able to change the syntax to give the best developer experience to JavaScript programmers. [18]

In 2020, BuckleScript introduced a new syntax that started to diverge from Reason. [19] A month later, the BuckleScript team rebranded its toolchain to ReScript, to focus solely on the JavaScript ecosystem and essentially becoming its own language, distinct from Reason. [20] [21]

To maintain the ability for Reason to target JavaScript, António Monteiro forked a version of BuckleScript before it was rebranded as ReScript, and changed it to bring it closer to the OCaml ecosystem. The fork, named Melange, released its first stable version in 2023. [22] [23]

See also

References

  1. 1 2 Walke, Jordan (May 16, 2016). "Initial Release: reasonml/reason". GitHub. Retrieved December 22, 2025.
  2. "Release 3.17.2". November 30, 2025. Retrieved December 1, 2025.
  3. "Melange". Reason Documentation. Retrieved December 20, 2025.
  4. Rafatpanah, Raphael; D'mello, Bruno Joseph (February 28, 2019). ReasonML Quick Start Guide. Packt Publishing. p. 6.
  5. Eisenberg, J. David (April 9, 2019). Web Development with ReasonML. Pragmatic Bookshelf. p. 170.
  6. 1 2 Eisenberg 2019, p. 15.
  7. Eisenberg 2019, pp. 1–4.
  8. "The OCaml Language - Parenthesized Expressions". ocaml.org. Retrieved September 30, 2025.
  9. De Simone, Sergio (November 10, 2017). "Facebook Overhauls ReasonML Syntax in Reason 3". InfoQ. C4Media. Retrieved January 3, 2026.
  10. Rafatpanah & D'mello 2019, p. 17.
  11. "Way, Way, Waaaay Nicer Error Messages!". Reason. August 25, 2017. Retrieved January 3, 2026.
  12. ReasonReact home page
  13. Rafatpanah & D'mello, p. 1.
  14. ReasonConf (November 29, 2019). Jordan Walke - React to the Future (video). Retrieved December 21, 2025 via YouTube.
  15. "Reason". Facebook. Archived from the original on May 17, 2016.
  16. "BuckleScript: The 1.0 release has arrived!". Bloomberg. September 8, 2016. Retrieved December 21, 2025.
  17. "Why Melange". Melange Documentation Site. Retrieved December 21, 2025.
  18. 1 2 Zhang, Hongbo (February 7, 2021). "A Short History of ReScript (BuckleScript)". OCaml Discourse. Retrieved December 21, 2025.
  19. Lou, Cheng (July 1, 2020). "A New Syntax for BuckleScript". ReScript. Retrieved December 21, 2025.
  20. ReScript Team (August 10, 2020). "BuckleScript & Reason Rebranding". ReScript. Retrieved September 11, 2022.
  21. Yang, Danny (December 2022). "Introduction". Introducing ReScript: Functional Programming for Web Applications. Apress.
  22. Monteiro, António (June 2, 2023). "ANN: Melange 1.0 – compile OCaml / ReasonML to JavaScript". OCaml. Retrieved May 24, 2024.
  23. Monteiro, António (June 2, 2023). "Melange 1.0 is here" . Retrieved December 21, 2025.