A ReasonReact Tutorial
Reason/OCaml has brought back my love of programming. It is functional, statically typed, and extremely pragmatic. You can program it just like an imperative language and write mutating code without any ceremony, or you can write purely functional code and get the benefits of equational reasoning.<p>The pragmatism comes from the fact that you can use it today on the browser. Unlike most other compile-to-js languages which are fairly new, OCaml is a mature language with a stable ecosystem. Its history dates back to the 80s when Robin Milner et al started building a theorem prover which evolved into a language that can be used for general purpose programming with strong compile-time guarantees thanks to the Hindley-Milner type system.<p>Reason is a new syntax for OCaml, and it is being lead by Jordan Walke and Cheng Lou. Jordan prototyped the first versions of React in OCaml, and React has planted nubs of FP ideas like immutability, and introduced a functional approach to building composable UIs which has so far been dominated by object-oriented mutation-heavy paradigms. The team is taking it one step further by bringing the entire FP paradigm to the browser.<p>The Reason syntax is currently functional just like OCaml and Haskell:<p><pre><code>  let sum a b => a + b;
  print_int (sum 1 2);
</code></pre>
The Reason team is considering changing it to a syntax that ALGOL-style programmers are familiar with. There are more details here: <a href="https://github.com/facebook/reason/pull/1299" rel="nofollow">https://github.com/facebook/reason/pull/1299</a>. So it'd become:<p><pre><code>  let sum(a, b) => a + b;
  print_int(sum(1,2));
</code></pre>
So in essence Reason can be considered a super-set of Javascript that adds powerful static typing, immutable values, and almost-first-class modules. This will greatly remove a source of friction for programmers new to FP, and in turn should help in the mainstream adoption of a strongly typed functional programming language. I think this would be a wonderful thing for practicing programmers in that more of us will be able to enjoy statically typed FP, and for the industry in general because we can now expect better programming practices and more robust systems.