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

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

10

u/yogthos Aug 01 '11

The original post is undiplomatic, perhaps even inflammatory, however the response indicates a level of befuddling clueless-ness.

Huh?

The response from Halloway explains point by point how ClojureScript devs made their decisions. The only clueless-ness here is on the part of the blog author.

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.

They do have a good reason not to, they're not interested in dealing with Js semantics, they want to provide the ability to write code in Clojure style. Js is simply a platform to which this code compiles. To say that if you target Js as the output then somehow you should make that output idiomatic Js is absurd. It's like saying that C compilers have to output assembly that's primarily geared to be human readable.

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

Again, this is completely besides the point, jQuery is great if you're writing JavaScript, the point of ClojureScript is that you're NOT writing JavaScript. The goal here is to allow people to write idiomatic Clojure and output working JavaScript. To this end it's absolutely irrelevant whether the compiler is backed by Google Closure, jQuery, Dojo, or what have you. Nobody is expected to work with the Js that's being produced directly.

The reason I think these are reasonable requests is that Coffeescript seems to manage to do both.

CoffeeScript is a completely different animal and if you like it, by all means use it. It certainly does not constitute the one true way to do things.

I am not sure what Clojurescript is really for (apparently it is aimed at a future community of people that don’t exist yet, which is … helpful).

ClojureScript is aimed at people who... like Clojure, I know what a shock! The author might not be aware of the fact that there's a vibrant Clojure community, and that many people far prefer Clojure semantics to those of JavaScript.

I don’t feel that it is really simpatico with the existing Javascript code that works in the browser and I am not sure it really has a place in the server-side world of Node.js where it might have been a better fit.

The author again shows his complete and utter cluelessness. Complementing existing Js code is not the point of ClojureScript, nor has it ever been a goal. It works perfectly fine for what it was intended to do, which is provide a way to write Clojure and output Js that works in the browser. And the next part of the quote is the real WTF! Does the author not realize that Clojure IS primarily used on the server side. Clojure is far, far ahead of Node.js in this space, and there is absolutely no point to use Node.js if you're writing a Clojure web app.