4 ms·
Is there a good reason to learn ReasonML instead of OCaml these days, or should I just learn OCaml + js_of_ocaml? I'm interested in building web apps, web serv
by modernerd 6y ago
Is there a good reason to learn ReasonML instead of OCaml these days, or should I just learn OCaml + js_of_ocaml?
I'm interested in building web apps, web servers, and simple WebSocket servers. OCaml appeals to me because it has more escape hatches than Haskell and is higher level than Rust, but I've always found the ReasonML vs OCaml story confusing.
- wk_end 6y agoI'm one of the weirdos who likes OCaml syntax, but in my eyes ReasonML is unfortunate. It fractures the community for (ironically) no real reason - not only is it a new syntax, they're now writing a new standard library for it (Belt), as though the three existing ones (plus the JS one!) weren't enough! I don't think the new syntax is particularly nice either. I don't think js_of_ocaml supports any kind of JSX. That's the only real reason to use Reason over OCaml that I know of, and it's a good one. But if I'm being frank, even if OCaml/Reason is a nicer language overall, TypeScript is a statically-typed frontend development story that has way more community buy-in and way fewer rough edges in the ecosystem. Just use it.
- zbaylin 6y agoBelt isn't a standard library for Reason, it's a standard library for Bucklescript that has specific optimizations since it knows it's going to be compiled to JS. Reason uses the same Pervasives/Stdlib as OCaml.
- modernerd 6y agoThat's helpful, thanks. The recent syntax switch[1] does feel like it will further fragment the community. And TypeScript has some pretty attractive functional projects: https://github.com/gcanti/fp-ts https://github.com/gcanti/fp-ts https://github.com/Matechs-Garage/matechs-effect https://github.com/Matechs-Garage/matechs-effect [1]: https://reasonml.org/blog/bucklescript-8-1-new-syntax https://reasonml.org/blog/bucklescript-8-1-new-syntax
- brmgb 6y agoThere isn't much to fragment to be honest. From what I have seen, there seems to be little buy-in for Reason in the Ocaml community which is not particularly surprising considering it's supposed to solve a pain point no one in the community actually has (Ocaml syntax is fine - it's obviously more Algol-like than C-like but clearly the existing community doesn't care). Reason seems to be mostly pushed by Facebook towards Javascript developers. That might work. Then again, esy is nice.
- smabie 6y agoI don't really think ReasonML provides much value, and would personally stay away from it.
- zbaylin 6y agoIf you think of ReasonML as a separate language (as I find it all too often is described), then it doesn't provide any extra value. However, as someone who is a contributor to Revery, a fairly large Reason project, the benefits of using Reason over OCaml are: - JSX. OCaml has infamously never had a great UI lib, even though the language parallels with many of the functional paradigms popularized by React. JSX is a great medium to bridge that gap. - The syntax itself. A lot of the contributors to Revery have no OCaml background, but rather JS since it's often billed as an Electron alternative. Reason's familiar syntax opens the door to many people who would be turned off by OCaml's "obscure" (not my actual thoughts) syntax. - The tooling. Since it's just an alternative syntax for OCaml, you get all the OCaml tooling for free, plus the Reason-specific tooling. I'm a huge fan of refmt, which is a tool that parses and formats Reason source files. Sure other langs have close-ish equivalents (i.e. clang-format), but refmt is much more opinionated, meaning you never have to worry about intricacies with your formatting.
- sweeneyrod 6y agoThe situation with Reason is (arguably needlessly) confusing. Reason is just an alternative syntax for OCaml, despite being often advertised in combination with BuckleScript (the more recent OCaml to JS compiler). You can use either Reason or OCaml syntax with either BuckleScript, js_of_ocaml or natively (very confusingly there's also a new slightly different version of Reason for BuckleScript only which you can ignore). The advantages of Reason syntax over OCaml are pretty much limited to a nice JSX syntax. For frontend development BuckleScript is probably better than js_of_ocaml in terms of integration with JS, bundle size and number of users. For backend development I personally think native OCaml (or Reason if you prefer it) is definitely usable. But you could also try BuckleScript bindings to node stuff if you really like node.
- yawaramin 6y agoReasonML is a syntax and a set of tools. If you prefer the OCaml syntax, by all means use that. If you prefer the standard OCaml tooling, by all means use those. A few reasons to look at Reason might be: - It gets rid of syntax ambiguities like the 'dangling else' problem - It introduces conveniences like line comments and JSX - The tooling includes Esy, which offers an npm-like package management experience including lockfiles and build artifact caching for faster builds across projects - The community is nice, close-knit, and helpful.
- deleted 6y ago[deleted]