ReasonML: The powerful JavaScript transpiler in check

Anyone looking for a transpiler for JavaScript has recently come across ReasonML. How does the young language compare to Elm – and how do you get started? An overview.

In web environments, nothing works without the JavaScript programming language. Accordingly, it is also popular as a target language for transpilers – that is, compilers that translate the source code of one programming language into the source code of another programming language. Development teams like to fall back on Transpiler languages ​​such as TypeScript, ReasonML and Elm, because these bring advantages such as static typing, the use of modern language features or better syntax for functional programming.

Static typing and functional programming are particularly interesting here. Static typing can help identify errors early on, and compilers are often better able to optimize statically typed code. In addition, integrated development environments (IDE) offer better auto-completion. Functional programming helps with concepts such as immutability, i.e. unchangeable values, and the stateless programming model, to develop code that is easier to read and easier to maintain. At this point, it is worth taking a look at the advantages and disadvantages of the individual transpiler languages ​​in order to help developers decide which language is suitable for which team project.

Elm is more based on Haskell and brings along other functional programming concepts. Developers appreciate the Transpiler language especially for the user experience and the lack of historical legacy. In addition, the standard libraries convince with well thought-out concepts and astonishing consistency. Another advantage is that Elm combines its language concepts with a framework for web development. The so-called “Elm architecture” is considered exemplary: State management has also established itself outside the community and served, for example, as a model for the JavaScript library Redux. The standard example from the Elm tutorial is a counter that can be increased or decreased at the push of a button:

main =
Browser.sandbox { init = 0, update = update, view = view }
type Msg = Increment | Decrement
update msg model =
case msg of
Increment ->
model + 1

Decrement ->
model - 1

view model =
div []
[ button [ onClick Decrement ] [ text "-" ]
, div [] [ text (String.fromInt model) ]
, button [ onClick Increment ] [ text "+" ]

However, the interaction with existing JavaScript libraries and frameworks for Elm apps is rather difficult. As a result, for example, the “backend-as-a-service” provider Darklang turned away from Elm and converted its entire platform to ReasonML.

You might be interested in that too

Ready to see us in action:

More To Explore
Enable registration in settings - general
Have any project in mind?

Contact us: