3 ms·
The short answer is that Reason's syntax is simpler and more enjoyable to use. I simultaneously learned both OCaml and ReasonML syntaxes and find Reason to be m
by quicksnap 9y ago
The short answer is that Reason's syntax is simpler and more enjoyable to use. I simultaneously learned both OCaml and ReasonML syntaxes and find Reason to be much easier to work with.
Perhaps people in Reason core will chime in with a more detailed answer. Here's some official information: https://reasonml.github.io/guide/ocaml/ https://reasonml.github.io/guide/ocaml/
- noncoml 9y agoYeah, I guess the complaint comes from a guy that was already familiar with OCaml's syntax. I guess if you don't know OCaml, maybe the Reason syntax is more appealing.
- lilactown 9y agoI do miss a lot of the parentheses-less-ness of OCaml (and the old Reason syntax), but I'm honestly a lot more comfortable at least broaching the topic of using it on some work projects now that it's more JavaScript-y.
- jordwest 9y agoI learnt Reason syntax first, then OCaml second. I prefer the OCaml syntax, it seems simpler, cleaner, and doesn’t hide the nice things about the language behind JavaScript semantics. The biggest example I can think of is that OCaml uses let..in, which reminds you that every function is a statement. By contrast, the `;` in Reason hides that fact. That said, it was the Reason syntax that first brought me to the ecosystem, and I think it’s going to be the catalyst that makes OCaml a big player in front end.
- jordwalke 9y ago> “The biggest example I can think of is that OCaml uses let..in, which reminds you that every function is a statement. By contrast, the `;` in Reason hides that fact.” ... Except in OCaml modules/files where you don’t use “in”. OCaml still has “semicolons” for let bindings - but they are just spelled as “in” or “let () =“ depending on the the context. All but one of these “semicolon” forms have nothing to do with language semantics and are only used to help the parser figure out how to group bindings and values. It doesn’t make OCaml’s core semantics worse or better- though it might make it harder to learn initially or copy/paste code between different contexts. The point of ; in Reason is merely for consistency - to have exactly one way to form bindings whether you are in a module or expression, allowing you to copy paste lines between the two contexts. Compare that to OCaml which requires different syntax depending on the context and copying values from module bodies to expressions requires a lot of editing. There may be other ways to achieve the same kind of consistency without semicolons and we are open to them - just so long as they are consistent across all contexts and easy to learn. (And as long as they don’t have major foot guns like JS’s ASI). (Often people object to ; as a parsing separator because they think it means “side effect”. It doesn’t. Not in Reason. Not in OCaml. OCaml features ubiquitous use of semicolons for everything from arrays, lists, to records field separators, all things that have nothing to do with side effects. And if you still haven’t had your fill, there’s the ;; double semicolon - which actually does typically imply side effects).
- bad_user 9y agoOCaml's syntax on the other hand is stable, whereas it is my impression that ReasonML changes with the same frequency that JS libraries are changed. And the differences are very superficial. What trips people is not the actual syntax, but the concepts learned, the rules of the type system, scoping rules, etc, which don't change. I'm glad that ReasonML exists, but personally I would use OCaml instead of risking that my codebase gets stuck with an old release after only six months because the current version now has different opinions about how to express anonymous functions.
- lilactown 9y agoYou're right in that ReasonML syntax is a bit of a moving target, but I think it's part of the initial pains of their effort to provide an approachable port into the ML world. The syntax should stabilize eventually. The maintainers are aware of the churn they are creating, and have deemed it worth it. That being said, I have a bunch of old projects written in Reason 2 (which still work; the tooling has preserved perfect backwards compatibility[0]), and recently started a new project using the new Reason 3 syntax. It was easy enough to pick up the new syntax in about a day. I haven't done it yet, but my understanding is that it's completely automated[1]. [0]: https://reasonml.github.io/community/blog/#reason-3 https://reasonml.github.io/community/blog/#reason-3 [1]: https://github.com/reasonml/upgradeSyntaxFrom2To3 https://github.com/reasonml/upgradeSyntaxFrom2To3
- jordwalke 9y agoWe provide tools to automate the upgrade between any two reason versions. It’s actually pretty trivial to keep up with changes due to refmt.