clojurescript

Aurélien Plazzotta 2025-05-24T21:47:20.983359Z

Hi! Is the learning curve steep to learn ClojureScript after having developped some basic knowledge from Clojure? Or are the 2 languages entirely different?

Noel Rivas 2025-05-25T19:05:33.770219Z

> I thought learning solid basics in Clojure would help expedite the process faster but I was clearly dellusional. I wouldn't go as far as saying that idea is delusional. From my brief experience I'd say that there is a gap but once you have a project set up and the REPL running, you'll move fast. Macros, as @potetm mentioned, require some ceremony. Other small differences cause unexpected effects occasionally but for the most part, I'd say it transfers. This, said by someone who started recently, and started with CLJS, so a spoonful of salt is advised.

raspasov 2025-05-25T21:53:25.206829Z

If you know Clojure at a solid level, switching to ClojureScript will be only 10-20% of the total extra effort (assuming you’ve had prior experience with JavaScript and the platform you are targeting with CLJS - node, browser, etc). Tooling/building is a bit different but that stuff you only “learn”/research once and mostly forget. “Thinking in data” is the same, interop is the same. That’s 80% of “getting Clojure”. Macros are well beyond “solid basic”, or even intermediate level… I spent years using Clojure and barely wrote any macros. Unless someone has had vast prior LISP experience, I would strongly discourage macros at the start.

James Amberger 2025-05-24T22:03:35.454059Z

Qua language I think it is fair to say that they are the same language. The learning curve from one to the other depends on the execution target, e.g. if you’re running cljs code in the browser you will probably need to know something about programming for the browser or at least rely on libraries that do. There are also some platform primitive gotchas, i.e. in clojure a string is a java string but in cljs a string is a js string, et cetera.

2025-05-24T22:24:02.540429Z

The biggest hurdle is probably the compilation model. 1. Compilation happens in the jvm, so there’s some weirdness around macro definitions. 2. cljs has multiple compilation optimizations, and the most aggressive optimizations(i.e. prod mode) munges symbols so you have to make sure you tell the compiler what symbols aren’t safe to munge. Another major hurdle is that namespaces don’t exist like they do in clojure. Lastly, to run a repl you now need at least 2 processes: the jvm (compiler) and the js runtime.

➕ 2
Aurélien Plazzotta 2025-05-24T22:28:30.237259Z

Allright, thanks for those feed-back. So there is a real gap between the two. I would like to read and put online the apps explained through the book Learn ClojureScript from Andrew Meredith and I thought learning solid basics in Clojure would help expedite the process faster but I was clearly dellusional. Thank you again for pointing out those caveats :-/

2025-05-24T22:31:55.599919Z

The way regular functions work more or less translates, but yeah there’s a fair amount of separation between the two langs to use them effectively.

Aurélien Plazzotta 2025-05-24T22:37:38.566179Z

Do you think that using a Clojure web-framework like Kit or Biff would circumvent the need to learn ClojureScript to do web programming?

2025-05-25T00:24:05.113999Z

If you’re not familiar with either clojure or clojurescript, not at all. cljs just has more concepts to add, more or less.

2025-05-25T03:41:07.001119Z

ClojureScript is used to program the browser. Same as JavaScript. For client side rendering. So if you want to build websites that are interactive beyond what HTML/CSS can do. Then you'll mostly need to use ClojureScript. Otherwise you can get away with just Clojure and server side rendering.

2025-05-25T03:42:31.111329Z

Or to put it another way, what you can do with Ruby on Rails, you can do with Clojure. But if you need React or jQuery, and so on, you'll need ClojureScript (or you'll need to use JavaScript)

raspasov 2025-05-25T04:05:22.588309Z

The languages are very similar; I believe the goal always has been “same language, on a different platform”; no effort to superficially paper over platform differences though (numerics, exception handling, etc)

raspasov 2025-05-25T04:08:01.190589Z

In vast majority of cases, non-interop code transfers 1:1

raspasov 2025-05-25T04:08:33.656479Z

FWIW, I’ve heard of people using ClojureScript on the server, with node.js, etc

raspasov 2025-05-25T04:08:48.540539Z

So it’s not only for browser (but I assume majority of the usage is there)

raspasov 2025-05-25T04:14:18.799789Z

To run a CLJS REPL (on Mac, assuming node is installed)

clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.repl.node