Hello everyone,
I have already posted this on reddit (in r/reactjs), but then it occurred to me that this would be even better place to ask my question(s), so I am C/P-ing it from there.
In advance I apologise for the long post, I just started typing and I haven’t realised how much did I actually write
My team is about to start rewriting our current Cordova app to ReactNative. The app is B2C fitness app, with 2M+ users and after some thinking we decided that RN would be way to go. Our dev team is pretty small - there is 3 of us, we have JS background and background in OO languages such C# & Java.
We have almost no experience in React / React Native (but we have used other JS frameworks like Angular, Kendo etc.). We have had built 2 “playground apps” to test out some features, to get feeling how it is to develop in RN, to see which technologies/libraries and which project structure we will use. We decided to go with TypeScript, Redux and redux-saga (I must point our that we absolutely LOVE sagas).
But, then couple days ago I watched some React conference on YT and noticed this “thing” called ReasonML - so I dug a bit deeper and I really liked what I saw - Strongly typed, functional, immutable language which compiles to JS. Now, I must point out that I really don’t like Javascript (almost hate it, probably because of my C# background), so when I found that there is language which I can use instead of JS to write RN apps, I was: fu** yeah :D! (and other teammates are not that into JS).
So I decided to start another playground project which would fetch news from HN and display them with FlatList just to get feel of ReasonML and I really liked it.
Here are some of my thoughts / experiences after just couple of days with ReasonML
(I apologies in advance if I misunderstood smth., or I am saying smth. that is just plain stupid, as said earlier, I have almost no experience with React, and even less with ReasonML):
GOOD STUFF
- Type safety and static code analysis are awesome and language is really expressive
- Type safety with ReasonML is on whole another level from TypeScript (and Flow) - it is like that with TS you describe / suggest that some value is of some type, but in ReasonML that value actually is of that type)
- Less external dependencies: In order to make JS less painful and more maintainable I had to install TypeScript, TSLint, and Prettier - in ReasonML you get all of this immediately
- There is ReasonReact - which makes React components first class citizens of ReasonML
- Redux is baked into ReasonReact - each component can have state, actions and reducers (just like in redux)
- It is easy to include ReasonML outputted JS into existing JS code
- ReasonML has some pretty nice things such as generics, variants, modules etc.
- You can call JS functions from ReasonML, even write pure JS inside Reason files
- Even though that “primary mode” of variables is immutable, you can mutate them if needed
PROBLEMATIC / BAD STUFF
(at least for me, with my limited knowledge of ReasonML and most of these are because ReasonML is, if I am not mistaken, around 2 years old)
- Community, even though really really great (you get answers on Discord like immediately) is small
- Which means there is scarce number of examples, best practices etc.
- For example “Redux” in ReasonReact is great solution for managing local state of component (and children) but there is no agreement / best practice on how to manage Global state of the app, at least I am not aware of it, more info here (What's the best way to handle global state in ReasonReact?)
- Regarding previous point some proposed solutions would be much better when new React Context API is introduced in ReactReason and when you browse Discord history, and comments around web - this was just around the corner, but then plans for introducing Context API to Reason have been “cancelled for now”
- Regarding previous point - there is little known about future plans and what we can expect form ReasonML and ReasonReact (for example maybe they are working on smth. even better than Context API so we won’t need it in ReactReason)
- If we want to stay in ReasonML world and call some existing JS libraries or external React components, we have to create bindings our selfs - for example if I am to use some RN in-app payment library, or some RN crash reporting / logging library I will have to write bindings by my self (because community is still young and there is small chance that someone has done this) - this can take a lot of time especially when adding more and more community made RN components like FastImage, or NativeBase etc.
- Handling side-effects is done via callbacks which I absolutely hate and code is really ugly, there have been some talks for almost a year about brining async / await into ReasonML, but nothing yet
- Documentation is ok, but could be much better
I know that everyone in ReasonML team and community is working really hard and I really do like it and believe it has potential to become the “next big thing” but I am not sure is it right for us at this stage.
I still cannot predict will it make us faster in the long run or slower (type safety = less bugs = more time for new features, on the other hand JS bindings will slow us down), will it make for great experience or will I pull my hair out when I step into callback hell?
We plan to have the same codebase for this project for next couple of years, so it is okay for me that first couple of months are hard, but after we get through initial troubles and pains we enjoy benefits of ReasonML (especially when community/syntax/tooling/libs become more mature and even better).
What are your thoughts and experiences with ReasonML?
Do you think my fears are unjustified and I mainly have them because of lack of knowledge and experience with Reason?
Do you think I should go for it, or choose “safer” route with JS/TypeScript?