Part 1 | Part 2

In the past several years, Reason has emerged as a key technology in new paradigms of JavaScript and TypeScript development. Renowned for its resilience and stability in mission-critical applications, Reason includes features that lend it a robust developer experience such as rapid-fire compilation, powerful type inference, and an emphasis on modular composition over inheritance. For these reasons, and due to its status as one of the more popular functional programming languages currently in vogue, Reason has seen widespread adoption in organizations as diverse as Fast-ED, Sotheby's, and the Coda blockchain. Moreover, Reason is immediately leverageable by React developers thanks to ReasonReact, and its visual similarity to JavaScript lends it a huge advantage in that compiled Reason resembles the precompiled code.

As part of our show Tag1 Team Talks, Michael Meyers (Managing Director at Tag1) and your host and moderator Preston So (Editor in Chief at Tag1; Senior Director, Product Strategy at Oracle; and author of Decoupled Drupal in Practice) invited Patrick Stapfer (Lead React Developer at Tag1; Member of the Reason Association) for a technical deep dive into some of the most salient and fascinating aspects of Reason. We also dug into real-world use cases and businesses of all sizes already utilizing Reason in production, as well as some of the key rationales that developers would want to adopt it in the first place. In this second installment of a two-part blog series about Reason, we take a closer look at why Reason's applications outperform their JavaScript and TypeScript counterparts and embark on a quick tour of Reason's community and burgeoning ecosystem.

Reason in the real world

Before moving forward, readers who haven't yet visited the first installment of this blog series will find that information useful for the rest of this article. That blog post contains a survey of Reason's most enticing features and includes coverage of some of Reason's most interesting examples in the real world for mission-critical applications that require a high degree of resilience and stability in production.

Some of the most well-known organizations in the world have adopted React, including McKinsey, SAP, Janestreet (a financial computing company), and other enterprise companies. But many smaller ventures and startups are also represented among Reason's user base, including Draftbit, which is architecting a no-code editorial experience for building React Native applications in Expo. A very complex project, Draftbit requires complex handling of context to ensure fealty to user expectations.

Examples in safety and blockchain

The Railway Safety App, developed by for French and Swiss railway systems, is intended for use as a traffic reporting tool. This is critical for situations where complex signaling mechanisms and train conductors need to be able communicate clearly with railway headquarters. For instance, if a train passes through a red light, the train conductor needs to immediately report back to mission control and inform them what happened and how it transpired. This reporting requires a complex form, and these form inputs need delicate handling due to the life-threatening nature of train incidents. Just like the Fast-ED case examined in the previous installment of this series, the requirement of a decision tree, a complex data structure, and complete coverage of all possible cases is palpable.

The Coda blockchain employs OCaml to perform block handling, but the blockchain wallet itself is actually an Electron application. In order to ensure a robust user interface that never fails for the end user, Coda's developers are utilizing Reason in order to have type guarantees for all inputs to the application. This is a fundamental requirement for blockchains, where immense amounts of cryptocurrency are stored, and a severe glitch or destruction in data could lead to the loss of valuable assets.

Reason for applications handling complex data and logic

For any developer team, building applications that gracefully handle complex data and logic is a challenging endeavor. Reason confers certain advantages in how it structures data, parses data, and expresses state. Consider, for instance, the common use case of rich text elements that contain complex formatting and can be nested in arbitrary hierarchies. Suppose you need to traverse one of these trees in order to render out the correct user interface elements in the presentation layer. Reason includes robust support for recursion, including tail recursion. This approach grants developers a pleasant developer experience when writing certain parsers.

Reason also has capabilities that make it a favorable choice for expressing complex React component state, a common problem for React developers. Consider a scenario where an object expresses a certain state in structured data, and this object is stored in a Redux store, which expresses a certain set of values. In the majority of cases, developers would prefer for this sort of reducer pattern to dispatch an action and, depending on the action, transform the state accordingly. And most of the time, this goes hand in hand with immutability so as not to mutate that object. In Reason, records, which are available by default, resemble objects in that they have closures and attributes, but they also compile to JavaScript objects such that they interoperate easily but remain immutable. Reason's immutable records can then be leveraged in the context of React components through hooks like useReducer(), and ReasonReact also makes available the use of useState() hooks.

Because everything revolves around modules, as mentioned in the first installment of this series, Reason also includes pattern matching. With a certain variant applied, developers can express certain states through words rather than complex logic. For instance, certain requests can end in success and contain a certain payload. Developers can express the intent of their state in real words without having to create a new object of a certain type with a particular action name. In this conception of pattern matching, developers can use Reason's built-in switch statement and match on specific patterns. Reason users can also check success response patterns to introspect the payload in order to seek a certain string that triggers further logic down the line. In this way, Reason's pattern matching feature eases the process of writing reducers as well as the challenges of handling and expressing state.

The Reason community and ecosystem

Reason is not just a functional programming language; it is also a fast-growing community and ecosystem made up of contributors and users from around the world. The Reason open-source community is composed of the Reason Association, the new Reason documentation platform, and ReasonConf, a conference now held in both North America and Europe. Patrick admits that the Reason community is a smaller community, but "it's a very focused and friendly community. Most people are aligned on certain values in that they have a certain paradigm in their head at a technical level, but at the same time they are also laid-back and helpful."

The best way to communicate with and get involved in the Reason community is to chat with users on Discord, where a Reason server is full of active members ready to offer support. In addition, there is the Reason Association, the foundation established to support Reason's open-source ecosystem and community and to further the advancement of the project, which is licensed entirely under MIT or still more liberal licenses. Currently, the Reason Association is in the midst of revamping, the documentation platform for Reason, to aid newcomers and make content more discoverable for searchers, including compiler specifics, syntax information, and API references. Patrick invites all contributors, including first-timers, to join the community in improving code, documentation, and other elements of the Reason ecosystem.

ReasonConf 2018 was the first conference for Reason. Its origins are in a small meetup group in Vienna, React Vienna, which has grown substantially over the years thanks to an influx of new members. ReactVienna community invited ReactiveConf speakers to have another dry run for their talk before the actual conference. This also attracted Reason team members and contributors. After some vivid brainstorming at the local event, the idea of having a dedicated ReasonML conference was born. The goal of ReasonConf 2018 was to offer every attendee the ability to write a simple React application using Reason in only three days across the span of the conference. Thanks to the presence of core team members actively working on the syntax and compiler, resources were at the ready throughout. Patrick encourages those interested in learning more about Reason in these turbulent times to host virtual meetups about Reason until the next in-person ReasonConf is possible.


In this two-part blog series, we covered some of the most fascinating features available to developers in Reason, a functional programming language that somewhat resembles JavaScript in its appearance but packs a host of other features into a cohesive whole. Reason contains a fast compiler, graceful type inference, and a preference for composition over inheritance, all of which lend themselves to a more resilient and stable application on the other side. In this blog post, we covered some of the ways Reason makes state handling much easier for developers, how Reason is benefiting some of the most popular names in the real world, and how you can take part in Reason's growing community and ecosystem.

Special thanks to Patrick Stapfer for his feedback during the writing process.

Part 1 | Part 2

Photo by Brigitte Tohm on Unsplash.