If so, do you think it has a big impact on your project?
I have been writing small snippets in both clojure and js (nodejs) and ignoring some clojure gems(immutability, macros - not that is hard working with just immutable objects and functions in JS) it equals to the same LoC, using ES6/7/8 and lodash, but I’m new to both languages.
If I had to ballpark, I’d say they’re probably in the same order of magnitude. The more general answer is that I don’t think LoC really means all that much. Some languages frankly have wider lines than others. The standard Elm formatter produces code so narrow that it looks like it’s supposed to be read on a phone. I don’t particularly love extra keystrokes, so in a vacuum I’ll take a terser language over a more verbose one, but there’s all the usual nuance underlying that preference: is it so crammed as to be unreadable, is it very difficult to write, etc etc etc.
When I compare JS and CLJS I focus less on character count than on whether one or the other has more default assumptions that I find comfortable and useful. CLJS has more of them, taking care of more things by default (if/case/cond-expressions, recursion, immutability, atoms, etc etc etc) than JS, which to varying degrees I need to wire up to do these things.
Sorry to be evasive
In my experience, cljs isn’t materially more or less dense than js on small, self-contained functions, like computing the average of a vector of numbers or something like that. But there are definitely libraries and frameworks where js gets incredibly verbose. Cljs solutions tend to be better equipped to deal with the boilerplate because it is so easy to make a DSL to deal with it. I’m thinking of things like react/redux vs reagent/reframe. Particularly in simple cases, like dashing off a button or some kind of decorated div, the reagent solution is much shorter.
Another example is manipulating deeply nested data. This is hard to do in js and the solutions that exist (lodash, perhaps) are kind of awkward. Compare with specter, which, arguably, is almost too dense for its own good.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.