thougthfulness of facebook's reasonml and reasonreact

Facebook recently released 0.3 version of reason and reasonreact for creating UIs. Instead of using typescript, you would use reasonml. reasonml is based on OCaml which has both functional and OOP capabilities.
Why is how facebook is integrating reasonml into their ecosystem brillant?
  • facebook recognizes that the ocaml syntax is a burden to learn. reasonml is a more javascript oriented syntax of ocaml. ocaml syntax is, as many functional languages are, harder to learn than say google’s go or really it’s difficult if you are not used to functional syntax. syntax is a big burden for migration of existing devs. The great part is that they are making it easy for a certain group, such as js programmers, to migrate.
  • facebook has created reasonreact using only a subset of ocaml. No OOP components. And they reduce the surface area of the reactjs APIs to something appropriate for the functional world. The API is small and easy to learn. It does not offer everything that the reactjs API offers but by not making the reasonreact hard, they can get started easily with a subset of react capabilities.
  • You can migrate one “file” at a time to reasonml which does not require you to migrate “everything” at once. Interop is good enough to make this doable. reasonml also has the ability to output .d.ts files for those using typescript in everyday use so that your code has some typechecking.
The expectation is that you would use reasonml instead of typescript. reasonml has immutability, currying by default and other things that typescript, as a superset of javascript, does not have built in. Both have a place.
You can also get the same benefits of reasonml using scala.js which has a reasonreact like wrapper plus a few other facades to choose from.


Popular posts from this blog

zio layers and framework integration

typescript and react types

dotty+scala.js+async: interesting options