Why ClojureScript?

Some of the reasons why I try to use ClojureScript for new projects are:

  • The functional programming paradigm makes problem solving easier/faster, and code becomes nicer i my opinion.
  • core.async makes asynchronous code a lot nicer, which is a huge boon on the HTML5/nodejs platform. Essentially you code that looks linear instead of callback hell.
  • core.logic gives access to to logic/declarative programming.
  • Immutable/persistent datastructures both supports functional programming, and when used it also improves the quality as many potential bugs related to mutable data are eliminated.
  • It is a hosted language, meaning it is very interoperable with the HTML5 host platform, – runs nice in browsers, nodejs etc., and you can use all the usual APIs easily.
  • It is Clojure, so code can be shared between the different platforms: JavaScript, JVM, .net.
  • The module system is good, – in contrast to the JavaScript-platform.
  • It has macros and meta programming support, which add an extra level of abstraction. This is also what enables logic programming, go-like asynchronous programming, optional typing etc. to be shipped just as a library, – where other languages would need to be reengineered.
  • The community feels both very bright and pragmatic.

Of course there are also some tradeofs:

  • Performance penalty, – it will be a bit slower if you write nice functional code, – but if you need really speed , you would rewrite the critical parts in C (emscripten) or GLSL anyhow. Also remember that the persistent datastructures build upon the assumption that we have a good generational garbage collector, which is not the case on all JavaScript implementations.
  • Compilation time/memory-usage is a bit high and requires java, which means it is not suitable for developing on phones/tablets(when offline) nor on low-end virtual hosts etc. (such as the c9.io development environment). Should have improved a bit recently though.
  • It is not mainstream which means it is more difficult get accepted into projects and find developers who already know the language (though a random Clojure developer is most likely a lot more competent than than a random JavaScript developer).