Hi there! I have just started learning about ReasonML and I am loving it so far. It's a new object-functional, OCaml based programming language created at Facebook. The official website says:

Reason lets you write simple, fast and quality type safe code while leveraging both the JavaScript & OCaml ecosystems.

Why learn it? The syntax is much closer to JavaScript as compared to say Haskell, Rust or even PureScript and elm. Reason would be a solid addition to your toolbox as a developer. It’s based on OCaml hence it can compile down to assembly, iOS, Android, JavaScript, and even microcontrollers.

OCaml is a language with a mature ecosystem of libraries which you can leverage in your code.

OCaml’s types have 100% percent coverage, which gives you great confidence in your code. There is first class support and tooling for working with existing JavaScript libraries. The compiler never gets in the way of your workflow, incremental builds on large codebases are under 100ms.

If you like working with React then you’re in for a treat. The creator of Reason (Jordan Walke) is also the creator of React, so you can be sure that introducing Reason inside your React app will be a breeze with ReasonReact.

Why do I need a type system?

One of the hardest part of programs dealing with UI is state and side-effect management. David Khourshid's React rally talk Infinitely better UIs with Finite Automata (highly recommended watch) demonstrates it a hell lot better than I can.

A large chunk of the code we write is to keep different parts of the UI consistent with the state. It's impossible to keep track of all the possible states and the paths between them inside your brain. It doesn't help that as the application grows, the number of possible combination of states increase exponentially.

Imagine not having to keep track of all the places you need to make a change when a new state is introduced. What if there's a system to help you consider all the cases and make it impossible to represent invalid states inside your code? Reason's type system does exactly that when leveraged correctly.

Before I can show you how to do this, I need to introduce some major concepts that help you write better code in Reason:

Compile time type checking