[2018-02-08] Warning: outdated content. Read the book “Exploring ReasonML”, instead (free online).
This blog post gives a brief high-level explanation of Facebook’s new programming language, ReasonML.
letbindings and scopes
Patterns and techniques:
This is what ReasonML code looks like (example taken from ReasonML’s online playground).
type tree = Leaf | Node(int, tree, tree); let rec sum = fun | Leaf => 0 | Node(value, left, right) => value + sum(left) + sum(right); let myTree = Node( 1, Node(2, Node(4, Leaf, Leaf), Node(6, Leaf, Leaf)), Node(3, Node(5, Leaf, Leaf), Node(7, Leaf, Leaf)) ); sum(myTree) |> Js.log;
ReasonML’s foundation, OCaml, brings the following benefits:
Full rebuild of the Reason part of the codebase is ~2s (a few hundreds of files), incremental build (the norm) is <100ms on average. The BuckleScript author estimates that the build system should scale to a few hundred thousands files in the current condition.
The ReasonML team also aims to improve the OCaml ecosystem:
createResource). OCaml uses snake-casing for lowercase names (
create_resource) and camel-casing for uppercase names (
OCaml’s pragmatism means that you don’t get some of the more fancy functional features (that, e.g., Haskell has), but it also leads to fast compilation, efficient code and decent error messages.