Reason Language Manual
#What Is Reason?
"Why bother learning an entire new language?"
This isn't what Reason is about.
However, it's unclear which features of JS to reshape, in order to fit it into the mold of a language designed around fast semantics and sound typing. But we can work backward, from a language that has been designed from the ground up around performance and safety, and make some adjustments so that it looks and acts a bit more like the better part of the familiar web language we've come to know.
All these decisions made it so that, for common use-cases, the learning curve of Reason isn't really higher than learning JS + a gradual type system; in return, you get:
A rock solid type system. OCaml types have 100% coverage (every line of code), inference (types can be deduced and aren't required to be written manually), and soundness (once it compiles, the types are guaranteed to be accurate).
A focus on simplicity & pragmatism. Reason allows opt-in side-effect, mutation and objects for familiarity & interop, while keeping the rest of the language pure, immutable and functional.
#Why OCaml As The Backing Language? Why Not [My Favorite Language]?
Many backing languages would satisfy the previous section's points; the points below, however, are important features of the OCaml language that make it particularly well suited as a foundation for Reason.
Side-effects, mutation & other escape hatches. These aren't usually the shiny selling points of a language; but being able to bridge toward a part of a codebase without an elaborate interop/rewrite is crucial for us at Facebook. OCaml defaults to immutable and functional code, but having the escape hatches makes the initial adoption sometimes simply possible.
Implementation polish matters. OCaml has been refined over two decades and gets better every year.
The language for writing React. ReasonReact demonstrates how naturally React patterns play to the strengths of OCaml/Reason, and ReactJS itself was inspired by the functional, yet pragmatic philosophy of the ML family of languages (as described in the React To The Future talk by jordwalke).
Welcoming, growing community. The Reason community is welcoming of newcomers. The community has members from all over the world. Join the Discord channel and ask for help. Stick around to share what you've learned with other newcomers.
#Reason isn't for you?
Here are some alternatives that share some similar concepts/lineage with Reason/OCaml, but often with a different focus:
OCaml. Reason is a syntax and toolchain built on top of the OCaml language. OCaml and Reason interoperate with eachother OCaml. You can compile plain OCaml with BuckleScript, and Js_of_ocaml can work with Reason as well.
Rust. Inspired by the ML family of langauges, but not garbage collected. Has excellent parallelism support.
Fable. Based on F#, which is closely related to OCaml.
ClojureScript. Dynamically typed language that prioritizes simplicity & great interop as well. Doesn't appear to have much in common with ReasonML. Shares some functional roots with the ML family of languages.
Swift. Language built by Apple, and interoperates with Objective-C well. Uses reference counted collection (but without automatic cycle breaking).
Haxe. Compiles to basically anything with a focus on game development.
Want to know more? Strike a conversation with anyone in the community!
Reason is an open source project that started at Facebook but that is heavily community built/organized.