What is ReasonML?
That being said, ReasonML is statically typed. While there is some data type inference in this language, it is primarily focused on your defining the data types throughout in the same way you would have in C or C++. ReasonML is also made to be type safe which can be a giant relief for many developers.
We also have numerous unique data structures that are pulled straight from OCaml that should enable some powerful functional capabilities. Many of these data structures are immutable by default which is especially useful if you are programming in a functional style. That being said, if you are needing to move in an imperative or object oriented direction, ReasonML does give some ways out to avoid too much inconvenience.
This moves us to our next language feature. ReasonML is primarily geared as a functional programming language which brings all the perks that come with it. The immutable data structures, first class functions, functional iteration methods specific to the different data structures, it's all there. However ReasonML does include some object oriented features to make it friendly to other programming needs.
Installation and Configuration
Now with all this being said, it's time to switch gears and move towards installing and configuring our systems to run ReasonML. First let's handle the installation through NPM. I already have it installed on my system so I will give you the terminal command for you to work with.
npm install -g email@example.com
That was easy. However, for some people, NPM or Yarn may not be an option. So we will also look at another way via OPAM which is the native package manager for OCaml. This is useful if you are coming from programming in OCaml and you just can't be bothered with installing Node and NPM. Bare in mind however that there are bugs to this approach if you are using Windows.
opam update eval $(opam config env) opam install reason.3.0.4 merlin.2.5.4
Now for our next step we need to configure an editor to work well with ReasonML. Depending on your editor of choice this can get more challenging than usual as ReasonML has a its own unique system of linters such as refmt (Reason Format) and Merlin which acts as the engine handling linting, refactoring, real time errors, etc.
So to get things moving in this tutorial, we will use the editor which is recommended to be the easiest to get configured and up and running with ReasonML and that is Visual Studio Code. If you absolutely do not wish to use this editor, a link will be provided below with the guides to get your specific editor set up to work with ReasonML.
Now let's open up Visual Studio Code and get Reason configured.
video showing ReasonML setup
Not bad, some others will be more challenging but now we should be ready to go.
Excellent, we now have an idea of what ReasonML is and what it has to offer, plus we have installed and configured ReasonML to our systems and we're ready to begin learning the fundamentals of the ReasonML language.