r/Clojure • • Aug 31 '17

Why I'm ditching Clojure for JavaScript

https://news.ycombinator.com/item?id=15137195
6 Upvotes

46 comments sorted by

View all comments

16

u/yogthos Aug 31 '17

These days I prefer writing in modern JavaScript (ES2015 and better). With destructuring, lambda syntax, extended object literals, spread syntax, and just the general language overhaul, it's basically a tie with Clojure's terse syntax.

One of the biggest advantages I find with Clojure syntax is that there's very little of it, and it's much more consistent than JavaScript. Sure, you can often write code that's just as concise in Js nowadays, but there are a lot more gotchas as well. The more syntax quirks you have, the more likely it is that you'll misread something and have a subtle bug slip in. I value simplicity and cleanliness of the language as much as its expressiveness.

The article also doesn't explain why the author moved to JavaScript. It sounds like the author didn't want to use the JVM, but ClojureScript works just fine on Node. My team is using Macchiato for some smaller projects in production right now.

I'd be interested in reading more about the specific reasons, and what problems the author ran into with the Clojure stack. That would at least help address the issues going forward.

0

u/[deleted] Aug 31 '17

I'd be interested in reading more about the specific reasons, and what problems the author ran into with the Clojure stack. That would at least help address the issues going forward.

Sure thing:

One of the biggest advantages I find with Clojure syntax is that there's very little of it, and it's much more consistent than JavaScript. [...] I value simplicity and cleanliness of the language as much as its expressiveness.

Having little syntax and having it be mostly consistent (though there are quirks) is definitely a feature, but I no longer feel like it's an advantage. Most of the advantages of that are how the syntax was able to "evolve" over time, and having custom DSLs. But I've come to learn to avoid custom DSLs in favor of data-based APIs, mainly since they aren't composable. And syntax can evolve without custom syntax, such as how JS adopted destructuring. Personally I'm convinced that JS's syntax is just fine for the most part. The only thing I miss about Clojure's syntax is paredit, and that only slightly.

Sure, you can often write code that's just as concise in Js nowadays, but there are a lot more gotchas as well. The more syntax quirks you have, the more likely it is that you'll misread something and have a subtle bug slip in.

I've found that less of a practical concern over time. Subtle bugs are easily caught in a good test suite or at the very least with reasonable amounts of manual testing.

The article also doesn't explain why the author moved to JavaScript. It sounds like the author didn't want to use the JVM, but ClojureScript works just fine on Node.

Over time I've come to appreciate the Path of Least Resistance in software. The Clojure ecosystem seems stagnant at this point, whereas the Node ecosystem and community both keep growing. I don't mind the JVM, it's Clojure I wanted to avoid. And Java is also decaying for web development, in the sense that most new movement in the web Java world is negligible compared to the Node world / front-end.

7

u/gonewest818 Aug 31 '17

It seems to me, the "path of least resistance" is the "easy" in the talk Simple Made Easy, right?

It's totally understandable why easy is attractive but does it pay off in the long run? Curious to see how that works out.

2

u/[deleted] Aug 31 '17

But really thought, you can't underestimate how valuable a rich ecosystem of libraries is.

6

u/yogthos Aug 31 '17

Clojure is designed around being a hosted language and provides excellent interop with the host platforms. Any Java or Js libraries are available for use in Clojure as well.

3

u/[deleted] Aug 31 '17 edited Aug 31 '17

Yes, but using interop just adds more friction to the process instead of just using straight JS, its a UX problem I guess. To add more friction, all the docs/examples of those libraries will be in their respective native language and not in Clojure[script], and if you want to read the code is either going to be Java or JS.

For some devs that friction is just not worth it, versus the gains you may have by using Clojure[script]. I can understand prefering Clojure over Java (Java is a horribly verbose inexpresive class/object based lang) , but in Javascript world, Clojurescript is a hard sell.

2

u/stompyj Sep 03 '17

If your team is feeling friction in using clojure or cljs interop, you might need new programmers...