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.

1

u/[deleted] Aug 31 '17

To some extent, easier is better, yeah. GardenCSS isn't really maintained so if I want new features I have to add them myself, whereas Sass/Less have most of the features I need/want, and they're still actively maintained. And if it takes me a few hours to jimmy-rig a Sass compiler into a Leiningen build so that we don't have to rewrite our Sass in GardenCSS, and if that rig is very unlikely to be maintained because of low/no outside interest in it, I have a lot less confidence in that bridge than using something like LessCSS, which actually was originally written in Ruby and then ported to JS because that's the direction things seem to be moving for a lot of projects. Looking at Jekyll, it's definitely got some major traction just by virtue of being built into Github Pages, but when I tried to port my home-grown JS static site generator for https://sdegutis.com to Jekyll, I just couldn't find tooling nearly as nice as what I already had. The live-reloading stuff in Jekyll was just non-existent, the Pug/Jade alternatives (Slim/Haml) were pretty lacking and not actively in development anymore. This same story happens time and time again in dying or stagnant ecosystems.

3

u/yogthos Aug 31 '17

That's a complete hyperbole. Adding lein-sass plugin literally takes minutes. You keep talking about Clojure ecosystem being stagnant, but you have yet to explain any concrete and tangible problems.

2

u/[deleted] Aug 31 '17

Oh right, I remember the problem with using lein-sass. It used an outdated version of Sass, so we had to fork it in order to use a newer version with newer features.

3

u/gonewest818 Sep 01 '17

... and the pull request was rejected by the project?

2

u/[deleted] Sep 01 '17

I don't remember specifically about this project, but I do know there have been many times I have opened an issue on a Github project for a Clojure-specific library where it wasn't answered for years on end, and some still haven't been answered to this day.