ReasonML Workshop: Feedback and Sources

On Tuesday evening, a new edition of the Meetup Js-Star.Paris in the premises of JS-Republic, like every month, it was an opportunity to share between members of the JavaScript community. This edition was devoted to the language ReasonML.

meetup1-March2018
meetup2-March2018
meetup3-March2018
meetup4-March2018
meetup5-March2018
SG
As a reminder, ReasonML is a language developed by the Facebook teams and in particular by the creator of React. It's sort of a fork of OCaml but simplified and adapted to the needs and habits of JavaScript developers. Facebook also uses it for its messaging system.
If you are curious to test the Workshop at home, you will find below the link to access the sources of the project with the explanations of the exercises:
https://github.com/js-republic/reason-ml-workshop
You will notice that there are two branches, master et solution, the first allows you to carry out the workshop, and the second contains the fully corrected workshop.

What did we think of ReasonML?

Preparing for this workshop was very rewarding. Indeed, it was the first time that we developed with this language. Here's what we learned:

ReasonML's approach can be very frustrating.

Like OCaml and other languages ​​of the same genre, ReasonML imposes an important rigor. Clearly, when you develop with ReasonML, you spend 15 min fixing syntax, type, compiler issues. In the end, you only spend a minute on your web page, because almost everything works perfectly. This approach can confuse many developers used to using “pure” JavaScript. Instead, they tend to quickly develop, test in the browser, see that it crashes, fix, and start over. We spend more time thinking, less debugging with ReasonML 😉

Tools still need to evolve

Currently the best way to develop in ReasonML is to use Visual Studio Code with the ReasonML plugin and the compiler alongside. Even if we must already recognize that there is a great job done, there is still a long way to go on this subject. When a syntax error comes up (as it often does when learning a new language), the compiler often responds to you Error: 3096: on the affected line, while Visual Studio Code highlights the wrong line for you as incorrect. BuckleScript, the project that manages ReasonML -> JavaScript compilation, can also give you nosebleeds, especially when you have to create function signatures yourself to communicate with a JavaScript API.

The shadow of OCaml is omnipresent

As said above, ReasonML is in a way a “fork” of OCaml with a reworked syntax to meet the needs of web and JavaScript development. However, it is common to come across “.ml” files, extensions of OCaml, when looking for the native API implementation or when searching the community tools. Typically bs jest is a good example. Do not be afraid to read OCaml.

Abstractions & typing offer unparalleled power

The potential frustrations cited so far are not useless. Indeed, once we have passed the headaches of the rise in competence we savor the power of the typing checks made by the compiler (a bit like in TypeScript). We love these abstractions that make you disappear all the errors due to null ou undefined. We take great pleasure in writing elegant code. To my knowledge, only ELM offers the same level of language in the JavaScript world with equivalent community interest.