Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



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.


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.


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/


CORRECTION: it's require-macros not refer-macros.


ClojureScript has compile-time only macros, but they are handy for repetitive (set!) calls as in your example. You might want to look at the (attr) macro in the cljs-d3 source:

https://github.com/lynaghk/cljs-d3/blob/master/src/clj/cljs_...

which solves a very similar problem to the one you mentioned in the article. In this case it expands attr(hash-map) into multiple attr(key, value) calls at compile time.


Projects that aid metaprogramming in CS (please contribute):

https://github.com/clyfe/meta_code/wiki




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: