Hacker News new | ask | show | jobs
by Mimmy 1102 days ago
Might as well ask this here, but any thoughts on how ReScript / ReasonML compare to Elm, PureScript, or ClojureScript? If someone were looking for a fp language that compiled to JS, how would they think about the pros and cons of the available options?

Last discussion I could find was from 2018 [1].

[1] https://news.ycombinator.com/item?id=17910069

3 comments

Biased answer:

The biggest differences between Elm and ReScript/ReasonML as language features are bindings, JSX and purity. Bindings in Elm are cumbersome and limited (on purpose) while in ReScript/ReasonML are easy, more feature complete and a little more fragile. JSX is exactly as React, while Elm doesn't have it; some people prefer it, some people don't. I love it. Purity in general terms makes Elm more strict while ReasonML/ReScript allow impurity when needed, still most APIs enforce functional style, immutability and proper data structures.

Regarding community, there's drama everywhere not sure If I can do a good job here. Maybe community size Elm is much bigger than others, but they need to reinvent most of tooling that is done in JS and ReScript/Reason takes advantage.

I encourage to not rely on anyones opinion about what's better, because you listed 5 languages with opposite directions.

Try it out yourself and decide based on users/team needs. Cheers.

Clojurescript has a lot of interesting stuff behind it, but honestly Clojure stuff has a pretty high learning curve (CLI tools whose error messages are extremely unhelpful, docs that are pretty minimal, and other things that make falling off the happy path rough). I think it's a very interesting "serious" choice, especially if you also want to run stuff as Clojure. But I found it a bit hard to get into.

Purescript has, I think, some of the most interesting things going for it from a FP language, as its effects system paired with the very nice support for JS objects through Record means you can build effects systems like "this function reads from the DB" vs "this function writes to the DB", or "this function accesses a single user's data" vs "this function is multitenant". The FFI story is also very straightforward IMO.

ReScript feels close to Elm in that it's very focused on a straightforward usage of ML and isn't trying to be fancy. I haven't messed with it in a while but honestly OCaml is pretty straightforward and lets you easily fallback to simple imperative tricks in a way that Clojurescript and Purescript don't.

I think if you want to go full FP, Purescript has the most interesting stuff to bring to the table (and because it's not lazily evaluated the mental model is not hard). ReScript has the easiest onboarding IMO... and Clojurescript is good if you're into Clojure/lisp-y stuff in general. But they're all very distinct flavors and it's ultimately a bit of an aesthetic choice IMO

I have looked at or tried all of them, except Reason, about 1 year ago. Purescript has (had?) the best tutorial: Purescript by Example. I guess it's also suitable for somebody, who doesn't know Haskell's way of doing things: https://book.purescript.org/chapter1.html https://github.com/purescript-contrib/purescript-book

In order of time programming in each language:

Elm: no, because of the JS interop (didn't even try it).

Clojurescript: really slow REPL, uses Google's closure compiler which had it's own problems (I don't remember what these were, but something with modules). Both Emacs and VS Code (Cider/Calva) did have to many small errors and inconveniences using CS. All in all it had been an unpleasant experience.

ReScript: The language itself is OK-ish (I would have preferred OCaml syntax), the compiler is fast as OCaml. The generated JS is really readable. One year ago there had been no async and the documentation had been missing stuff like functors (I've "found" them at the Rescript forum). But in the end it didn't have enough advantages over TS to cancel out TS' _way_ better developer tools/integration or even Purescript, but this may have changed in the last year (async has been added and functors are now documented, as I've just seen). On the other hand, I would nowadays use Melange instead, I don't see any reason[what a pun!] to use Rescript any more.

PureScript: It is a better (strict) Haskell (with less features). I've used (non-hook) Halogen, I don't know about the React bindings. I had never made an web app (progressive or not) before, so I had to learn everything starting at 0. This has been the result, which has been a quite smooth experience: https://github.com/Release-Candidate/Notoy-PWA#purescript