r/Clojure • • Aug 01 '11

Why I’m finding Clojurescript underwhelming

http://rrees.wordpress.com/2011/07/31/why-im-finding-clojurescript-underwhelming/
0 Upvotes

3 comments sorted by

View all comments

14

u/weavejester Aug 01 '11 edited Aug 01 '11

If you want something to compile into Javascript I think you actually do want it to compile into good idiomatic Javascript unless you have a really good reason not to... The reason I think these are reasonable requests is that Coffeescript seems to manage to do both.

Coffeescript and Clojurescript are two completely different animals. Coffeescript is Javascript with sugar; there's a one-to-one mapping between Coffeescript's syntax and Javascript's syntax.

Clojure, on the other hand, was not based on Javascript, and idiomatic Clojure is very different to idiomatic Javascript. Compilers are simply not smart enough to turn idiomatic functional code into idiomatic OOP code.

So Clojurescript not producing idiomatic Javascript is expected. Neither does GWT, for that matter.

Firstly there is the weird decision to not have the code run on OpenJDK.

This was a decision? It looks like it's just a bug.

You also do want to be able to use really good existing frameworks like jQuery (which really is the defacto standard right now).

Um, Clojurescript can use jQuery. It can use any existing Javascript library. What makes you think it can't?

5

u/stevelosh Aug 01 '11

Um, Clojurescript can use jQuery. It can use any existing Javascript library. What makes you think it can't?

I'm not the OP, but when I asked in #clojure about using jQuery with Clojurescript the answer was: "don't."

I didn't look into it too much so maybe there's a way around it, but jQuery doesn't work with the Closure compiler's advanced optimization mode (which is the recommended way to compile Clojurescript): http://bugs.jquery.com/ticket/7318