(+ 1 “1”) is not a type error for CLJS, because it’s not a type error for JS. Clojure is designed as a hosted language and it shares all the basic types and operations with the host platform.
Clojure and clojurescript are both dynamically typed, but clojure is strongly typed (type errors throw exceptions), and clojurescript is weakly typed (type errors are technically valid code). Too many clojure enthusiasts act like they're both the same language, but that is an absolutely massive difference.
Try the following code out in each: (+ "1" 1). In clojure you get an exception, in clojurescript you get "11" (maybe a warning at compile time which won't show it's face at runtime when the data is fed to you from an API call).
That bug silently corrupted analytics data for 3 months for a service I worked on. That alone was the reason I stopped using dynamically typed languages.
Not really. Although Clojure and Clojurescript are both dynamically typed, Clojure is strongly typed while Clojurescript is weakly typed.
Clojure:
(+ "1" 1)
ClassCastException java.lang.String cannot be cast to java.lang.Number clojure.lang.Numbers.add (Numbers.java:128)
Clojurescript:
(+ "1" 1)
"11"
They may be close, but that is all the reason for concern. There are a million ways that small semantic differences like this can completely fuck you and leave you in a debugging nightmare. I would rather use javascript, AKA the worst language ever invented, than a language that claims to be cross platform but with semantics that change depending on the platform.
Sorry, but this is plain wrong. Clojure is a functional first language with an extremely powerful macro system. JavaScript has ad-hoc monkey patching and a heavy toolchain requirement to enable immutability.
ClojureScript is strongly typed. I'm curious to know the specific case they ran into? I suspect it might have been interop with JavaScript, because you shouldn't have weak types in ClojureScript.
Anything that isn't JavaScript is a rounding error. But that doesn't mean ClojureScript isn't viable: ~4000 Github stars, ~1200 subscribers to the mailing list, ~100 contributors, ~900 closed issues, ~170 daily lurkers on IRC, and probably the most comprehensive source mapping support of any compile to JavaScript language out there.
People use it happily in production. In the end that's all that really matters.
For the record, CLJS does count. And the tooling although painful is on par with the one found in JS (webpack). Maybe even a little less painful.
But one problem that ClojureScript avoids by virtue of being a 'hosted language' and not having a spec is having to implement its own numeric tower. Numbers can just be floats and move on.
CL mandates integers. Not just fixnums, like WebASM provides, but bignums. As well as rationals. That is a lot of code your run-time will have to provide.
iirc Whalesong (the Racket to JS implementation) bundled a numeric tower that implemented integers using strings).
It's all good. Everything being said, I appreciate efforts like ClojureScript. There is just so much power in being able to use the same language and share the same models on the front and back end, but not all of us want to use JavaScript/Typescript.
reply