Why I'm Not Using Clojurescript

| Comments

People all over the place have been promoting alternative syntaxes for javascript. The clojure community in particular has been working with clojurescript, the idea of using clojure in every part of the stack being very seductive. Here’s one reason why I’m not thrilled about using clojurescript:

The browser doesn’t speak clojure, it speaks javascript.

So switching to clojurescript adds a few constraints, which personally, I’m not thrilled about.

  • clojurescript is compiled into a fairly ugly bunch of obfuscated code, which is what one is dealing with whenever any debugging is in order.
  • it adds the google closure library to the dependencies, even if you’re just adding a couple of effects.
  • any moderately heavy client-side stuff usually needs some performance optimization, this means twiddly js stuff. Shall I use this function instead of this other? Shall I avoid this loop in favor of something else? This is made markedly more difficult when having to deal with a layer of indirection between the code you’re working on and the code actually running on the browser.
  • let’s not mention producing cross-browser compatible code, IE hacks are not nice and lispy, however you turn it.

Admittedly, the third point is also true for any high-level language – why not work in C instead of Ruby, Clojure, or others? However, javascript is no C, not in difficulty level. It’s not very pretty, it’s got warts that come with a long and twisted history, but it’s possible to produce fairly friendly-looking code. javascript by itself isn’t excruciating enough to justify the potential difficulty caused by using clojurescript.

I admit I’m sometimes a curmudgeon and resistant to change, so as always, happy to hear any arguments as to why I might be glaringly wrong.

(Note: do read the comments by Stuart Sierra and David Nolen, for a different point of view)