Indeed, the interop story is very well done, you can use anything written in Reason in OCaml syntax… but it comes with a price in UX (or DX?).
I have had the chance of exploring Bucklescript for the last few weeks, and I tried to stay with the OCaml syntax as it lets me familiarize myself to do OCaml backend stuff too.
From what I’ve seen, the whole Bucklescript community (which is most active on Discord) seems to lean more to Reason. There are many libraries and bindings written in or migrated to Reason. Everyone keeps saying that it is essentially OCaml, just with a different syntax—I’d like to argue that the different syntax bit is definitely not a just. That is, I think it causes problems. There are two reasons:
Context switching. You’re a beginner writing in OCaml. You got the basics worked out and doing well with your Bucklescript project. Then you need a library to do something, and when you explore Github you found that it’s written in Reason… It’s great if the lib author provides examples for both flavor, but if it’s only in Reason then mostly you’re on your own. Those little things like swapped type positions ('a list
vs. list 'a
, Js.Json.t Js.Dict.t Js.Promise.t
vs. the backwards version), different notations altogether (< .. >
vs {..}
, < foo : string; .. >
vs {.. foo : string}
, etc.). Those little damages might slow you down from actually getting things done. You end up copying and pasting stuff into the reason-tools extension every now and then.
Codebase inconsistencies. Other than syntax difference, Reason also has different conventions, one of them being identifiers using camelCase
instead of the usual OCaml’s snake_case
. In my experience, consistency across codebase is one of the major point of a great DX when navigating a project. When you interop, you’re intermingling both conventions in one place. In JS we even have linter rules for making sure these kinds of consistencies are enforced… Also, when I write a lib, should the API expose camel case functions? If I use snake case function, would Reason devs feel excluded? A bit exaggerated indeed, but I’d definitely prefer not to think about these things if possible.
I think these are even experienced by those who use Reason too, since Bucklescript’s manual is still in OCaml. There are talks to rewrite their manual in a more accessible way, and if they did rewrite it, I really hope they’d stick with OCaml syntax, or at least provide both flavor… although I realize that would mean more maintenance effort.
All in all, if I do Bucklescript stuff in OCaml, I can’t help but feel kind of like a douche that doesn’t want to “fit into” the community by consciously using different syntax
Note: not a jab at the community, though! I’ve been helped numerous times on Discord and I am very grateful for that.