Why Try ReasonReact?

09/09/20191 Min Read — In Reason, React.js

In the last few days, I've taken a look at Reason.

I'm interested in ReasonReact as an alternative to using JavaScript on the front-end.

I enjoy the style and patterns of functional programming languages.
While I can write vanilla JavaScript in a functional style, it's very brittle.

If you want to have immutable data structures, and better library support for a functional style, you have to shove in a ton of libraries like Immutable.js, Ramda.js, etc.

TypeScript comes to mind as the obvious alternative to JavaScript, as it is a statically compiled Javascript-sublanguage. But it's still a multi-paradigm language, and even favors object-oriented programming.

ClojureScript is a language that I enjoyed. But its toolchain and its support for modern React features are lacking. As a niche language, Clojurescript's ecosystem is smaller.
Reagent, the most popular interface for React, still doesn't support React hooks.

The tooling centers mostly around Java and the JVM, because everyone assumes that you use Clojure as the back-end language.

Clojure and ClojureScript are written for experienced programmers. There is no de-facto Clojure web framework. Clojurists use tons of different libraries that suit their needs. It's very confusing for newcomers to the language.
My experiences with Clojure, Clojurescript, JavaScript interop, and the tooling have been frustrating.
I'm sure that Java programmers will have a better first impression.

I'm not sure if Elm would be a good fit for me. But it seems like the Elm architecture makes it unnecessarily complicated to get things done.

Reason could be a viable alternative for using JavaScript/React.
It's functional, it's familiar, and it has first-class React-bindings.

Reason compiles to Ocaml under the hood. I don't know a lot about Ocaml. But from what I've read about Reason, its concepts feel very similar to Elixir (immutable data structures, pattern-matching, linked lists) - but with types.

I'm not too fond of Reason's syntax. Like JavaScript, all those brackets and semicolons are quite noisy.

But it's easy to get started as it feels like you're writing JavaScript.

I can see ReasonReact as the perfect companion for an Elixir web application. (I'm not sure if Phoenix and Reason play well together out of the box, though.)