Reason (programming language)
| Reason | |
|---|---|
| Paradigms | Multi-paradigm: functional, imperative, modular, object-oriented |
| Family | ML: Caml: OCaml |
| Designed by | Jordan Walke |
| First appeared | May 16, 2016[1] |
| Stable release | 3.17.2[2] |
| License | MIT |
| Filename extensions | .re, .rei |
| Website | reasonml |
| Influenced by | |
| OCaml, JavaScript | |
Reason, also known as ReasonML, is a general-purpose, high-level, multi-paradigm, functional and object-oriented programming language and syntax extension and toolchain for OCaml created by Jordan Walke, who also created the React framework, at Facebook.[3][4] 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.[5]
The Reason community officially provides ReasonReact as a solution for React-based web applications.[6]
Differences from OCaml Syntax
[edit]While Reason compiles down to native code via OCaml's toolchain, it specifically differs in its syntax, error messaging, and editor tooling.[7] This allows Reason to provide an experience more similar to JavaScript or TypeScript for developers, which some may be more familiar with.
While OCaml primarily uses parentheses or begin/end keywords to delimit blocks[8]—with nothing separating declarations—Reason tends to use curly braces to delimit blocks and semicolons for separating declarations. Like JavaScript, Reason also defines functions via arrow-like syntax rather than OCaml's fun keyword. Other notable differences include naming the pattern matching keyword switch (instead of match), and reformatting error messages to be more familiar to JavaScript programmers.
Example
[edit]type schoolPerson = Teacher | Director | Student(string);
let greeting = person =>
switch (person) {
| Teacher => "Hey Professor!"
| Director => "Hello Director."
| Student("Richard") => "Still here Ricky?"
| Student(anyOtherName) => "Hey, " ++ anyOtherName ++ "."
};
History
[edit]Jordan Walke, creator of React, created Reason in 2016 while employed at Facebook.[9][10]
In the same year, Bloomberg L.P. introduced BuckleScript, a compiler which compiled OCaml to JavaScript.[11] As both projects were influenced by JavaScript, Reason and BuckleScript soon became an integrated toolchain, allowing Reason to target JavaScript.[12][13]
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.[13]
In 2020, BuckleScript introduced a new syntax that started to diverge from Reason.[14] 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.[15]
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.[16][17]
See also
[edit]- Elm – A functional language that uses an abstraction called ports to communicate with JavaScript
- PureScript – A strongly-typed, purely-functional programming language that compiles to JavaScript
References
[edit]- ^ "Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems: facebook/reason". GitHub. Facebook. 2019-03-23. Retrieved 2019-03-23.
- ^ "Release 3.17.2". 30 November 2025. Retrieved 1 December 2025.
- ^ "What is ReasonML?". 2ality. Retrieved 2019-03-23.
- ^ Rauschmayer, Axel (2018). Exploring ReasonML and functional programming. ReasonML Hub. Retrieved 2024-05-14.
- ^ "Melange". Reason. Retrieved 2025-12-20.
- ^ "ReasonReact". GitHub.
- ^ "What & Why · Reason". reasonml.github.io. Retrieved 2025-02-08.
- ^ "The OCaml Language - Parenthesized Expressions". ocaml.org. Retrieved 2025-09-30.
- ^ ReasonConf (2019-11-29). Jordan Walke - React to the Future (video). Retrieved 2025-12-21 – via YouTube.
- ^ "Reason". Archived from the original on 2016-05-17.
- ^ "BuckleScript: The 1.0 release has arrived!". Bloomberg. 2016-09-08. Retrieved 2025-12-21.
- ^ "Why Melange". Melange Documentation Site. Retrieved 2025-12-21.
- ^ a b Zhang, Bob (2021-02-07). "A Short History of ReScript (BuckleScript)". OCaml Discourse. Retrieved 2025-12-21.
- ^ Lou, Cheng (2020-07-01). "A New Syntax for BuckleScript". ReScript. Retrieved 2025-12-21.
- ^ ReScript Team (2020-08-10). "BuckleScript & Reason Rebranding". ReScript. Retrieved 2022-09-11.
- ^ Monteiro, António (2023-06-02). "ANN: Melange 1.0 – compile OCaml / ReasonML to JavaScript". OCaml. Retrieved 2024-05-24.
- ^ Monteiro, António (2023-06-02). "Melange 1.0 is here". Retrieved 2025-12-21.
External links
[edit]- Official website

- Reason Project Organisation on GitHub
- Melange documentation site
- ReasonReact
- Cross-platform free software
- Extensible syntax programming languages
- Free and open source compilers
- Functional languages
- Object-oriented programming languages
- ML programming language family
- OCaml programming language family
- Pattern matching programming languages
- Statically typed programming languages
- Programming languages created in 2016
- High-level programming languages
- Software using the MIT license