Hacker News new | ask | show | jobs
by pizzeriafrida 1904 days ago
The question is funny because on the the list of advantages that Clojurescript offers the syntax / language is quite low on the list imo.

Clojurescript has the best client-side build tool I have used in https://shadow-cljs.github.io/docs/UsersGuide.html and everyone uses it.

Clojurescript targets/outputs Google Closure compatible code which is easily the most sophisticated JS compiler out there. The reason no one uses it is because writing compatible code by hand is a nightmare.

Clojurescript's front end libraries are incredible, they are basically a better expression of Redux because the Clojure language has constructs that enable a more expressive API https://day8.github.io/re-frame/re-frame/

Clojurescript's JS interop is actually insane, boosted by the quality of Shadow-cljs. You can write 1:1 javascript in clojurescript if you need to. A trite example would be npm installing lodash and writing some code that uses it, I have done this and it just works.

Clojurescript's developer experience with the browser repl is next level. I know a lot of the stuff I'm saying sounds hyperbolic, but I've written a ton of Javascript and react and I really like it still, but using a browser repl to manipulate application state in my editor and reload functions without a full refresh is great.

And I guess lastly, yea the language is awesome. It's basically my perfect version of Javascript. No need to fumble with libraries like immutable.js, no need for additional libraries like ramda or lodash because the standard clojurescript library has everything+.

3 comments

“It's basically my perfect version of Javascript. No need to fumble with libraries like immutable.js, no need for additional libraries like ramda or lodash because the standard clojurescript library has everything+.”

This pretty much my view as well. There’s that classic joke comparing two books on JavaScript, the complete language vs. the good parts [0], and you could pretty much just replace the “good parts” book with ClojureScript.

It has everything you need and gets rid of most of the stuff that enables people to write bad code. (Assuming you like functional programming, of course)

[0] https://i.redd.it/h7nt4keyd7oy.jpg

Sorry for what might be an obvious answer, but when you say

>because the standard clojurescript library has everything+

do you mean bc it has all those libraries incorporated, or bc it's able to emit the equivalent to native javascript?

Immutability is baked into ClojureScript, so there’s no need for libraries like Immutable.js. Likewise, ClojureScript is all about manipulating a small set of code data structures (lists, vectors, maps, etc), and as such it has an extensive (!) set of functions built into the core language for doing just that, which eliminates the need for libraries like Ramada and Lodash.

Behind the scenes ClojureScript is transpiled to pure JavaScript with Google’s Closure compiler, so there’s no external dependencies on libraries like the ones mentioned above. It’s all just built into the language.

Reading this and other replies I wonder why no one mentions core.async?
core.async is great, but admittedly I haven't needed to reach for it on the client (when building SPAs). I'm not sure if it's because re-frame is the focus for event driven workflows or what, but...