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

Over the years the language differences between Clojure & ClojureScript have more or less been erased beyond very host specific details like String methods, no multithreading, etc. Clojure 1.7.0 landed reader conditional which permits writing conditional code based on whether the file is being compiled by Clojure or by ClojureScript.

So we simply conditionalized a few key things in the analyzer and then we just point ClojureScript JVM back at its own sources. This part was actually very simple to do. However much more challenging is the issue of macros. As with many Lisps, Clojure has only a few primitive special forms and most of the language is actually written in terms of macros. ClojureScript is no different, the macros files is longer than the analyzer or the compiler.

You can see ClojureScript's meta-circular moment here - https://github.com/clojure/clojurescript/blob/d1d3e866440626.... The macros file must load itself in order for it to be compiled into JavaScript.

Google Closure was always an additional optimization pass. The bootstrapped code we generate is still Closure compatible making it easy to run it yourself seperately as an optimization pass or to produce a single JavaScript file you can put somewhere on the Internet if you like.



Awesome work David!




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

Search: