Hi! Is the learning curve steep to learn ClojureScript after having developped some basic knowledge from Clojure? Or are the 2 languages entirely different?
> 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.
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.
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.
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.
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 :-/
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.
Do you think that using a Clojure web-framework like Kit or Biff would circumvent the need to learn ClojureScript to do web programming?
If you’re not familiar with either clojure or clojurescript, not at all. cljs just has more concepts to add, more or less.
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.
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)
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)
In vast majority of cases, non-interop code transfers 1:1
FWIW, I’ve heard of people using ClojureScript on the server, with node.js, etc
So it’s not only for browser (but I assume majority of the usage is there)
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