
ClojureScript vs Coffeescript - DanielRibeiro
http://metaphysicaldeveloper.wordpress.com/2011/08/28/clojurescript-vs-coffeescript/
======
astine
Hmm. This seems like an odd comparison to me as Coffeescript and ClojureScript
really have two different target audiences. Coffeescript seem to be more
targeted towards people interested in writing JavaScript application with a
more clean syntax whereas it seems ClojureScript's aim is to allow people who
want to write Clojure, do so targeting a JavasScript VM rather than a JVM. I'd
expect people looking to use either would probably know which one they were
looking for from the get-go.

Interesting summary of ClojureScript's current weaknesses though.

~~~
swannodette
I think the audiences are not as different than you think (I use both).
CoffeeScript is for anyone wanting to write in a more expressive language.

ClojureScript offers that and even more without requiring people to fork
ClojureScript. For example I got my pattern matching library working for
ClojureScript - [http://dosync.posterous.com/advanced-pattern-matching-for-
ja...](http://dosync.posterous.com/advanced-pattern-matching-for-javascript).
match looks deceivingly simple, it's a fairly involved extensible optimizing
pattern match compiler implemented as a macro.

EDIT: a fun example of how expressive pattern matching can be - here's a
pattern for checking red black tree balance and the incredible output -
<https://gist.github.com/1177437>

------
janecoder
This is Pacman in Clojurescript: <https://github.com/mjg123/pacman>

This is Pacman in Javascript (I couldn't find one in Coffeescript):
<https://github.com/macek/google_pacman>

------
scottjad
60 of the ClojureScript lines are due to unidiomatic formatting of
parenthesis.

~~~
DanielRibeiro
Would love to get a pull request with an idiomatic version.

------
jhickner
Nice writeup! I hadn’t heard of rbcoffee before. I’ll definitely be using that
in my coffeescript projects. One point – doesn’t ClojureScript support user
macros via refer-macros? :

(ns my.namespace (:refer-macros ‘[my.macros :as my])

~~~
DanielRibeiro
Thanks. Rboffee has its own project[1].

About macros, I get _WARNING: Use of undeclared Var cljs.user/defmacro_ when I
even think of using them.

If you manage to use them, please let me know!

[1] <https://github.com/danielribeiro/rbcoffee>

~~~
swannodette
ClojureScript does indeed have macros. They are compiler macros. You can't
define macros in your ClojureScript file (because ClojureScript doesn't itself
have access to the compiler) but you can refer to macros defined in a Clojure
file and the ClojureScript compiler will use this to expand your
ClojureScript. That's what refer-macros is for. I'm looking forward to getting
my pattern matching library, <https://github.com/swannodette/match>, working
with ClojureScript.

As far as the compile times you should checkout Chris Granger's
<https://github.com/ibdknox/cljs-watch>. This is analogous to "coffee -wc
*.coffee".

Nice writeup.

~~~
benatkin
To me it was obvious that the time-to-compile measurement for ClojureScript
was all wrong. It's a common, but annoying mistake people who aren't used to
the JVM make. Startup Time != Compile Time.

~~~
DanielRibeiro
If it started once and watched files for changes, it would only be the compile
time (which, if fast, would be great). As it is, the total time is the only
one that counts, as it is the one that affects your productivity.

JRuby guys were so aware of this that they actively promoted nailgun[1].

[1] <http://www.martiansoftware.com/nailgun/>

