Part 1 | Part 2
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 CCA.io 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.
useReducer(), and ReasonReact also makes available the use of
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 reasonml.org, 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.
Special thanks to Patrick Stapfer for his feedback during the writing process.
Part 1 | Part 2