News for hackers. Stuff that matters.
Re:Replete – a standalone ClojureScript REPL for iOS by mfikes on Friday July 10, 2015 @10:27AM (#9864105)
Author here. Willing to answer questions.
Re:Replete – a standalone ClojureScript REPL for iOS by elbenshira on Friday July 10, 2015 @10:35AM (#9864155)
If I understand correctly, the ClojureScript compiler was written in Clojure (that is, you had to run the JVM to run the compiler), which spat out JS code and then compiled by Google Closure.

Would you be able to explain, at a high level, how ClojureScript bootstrapped itself, and how Google Closure comes into play?

Re:Replete – a standalone ClojureScript REPL for iOS by swannodette on Friday July 10, 2015 @10:50AM (#9864233)
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.

Re:Replete – a standalone ClojureScript REPL for iOS by kahunamoore on Friday July 10, 2015 @06:36PM (#9867346)
Awesome work David!
Re:Replete – a standalone ClojureScript REPL for iOS by dustingetz on Friday July 10, 2015 @10:45AM (#9864211)
Re:Replete – a standalone ClojureScript REPL for iOS by mfikes on Friday July 10, 2015 @10:51AM (#9864237)
One way to look at it: Replete has a bit of CLJS source which requires the reader, analyzer and compiler namespaces. When Replete's source is built (using the JVM), these additional namespaces get compiled down to JavaScript and are usable by Replete itself, in the R and E parts of the REPL. It is all JavaScript, of course, when on the device.

Google Closure is used for its dependency management (ClojureScript namespaces and how they require other namespaces). But Google Closure is not used for its optimizations (everything is built with :none mode).

Re:Replete – a standalone ClojureScript REPL for iOS by karlmikko on Friday July 10, 2015 @10:44AM (#9864205)
Yes the ClojureScript compiler is written in Clojure, more than that it is written in a special form of Clojure that can do conditional branching depending on what environment it is running in. So now the ClojureScript compiler can be ran in ClojureScript.
Re:Replete – a standalone ClojureScript REPL for iOS by escherize on Friday July 10, 2015 @10:36AM (#9864164)
Is there a way to pull libraries into the bootstrapped repl? I suspect lein (a bash script) wouldn't work.

Also: Are there talks or posts describing the future applications for bootstrapped ClojureScript?

Re:Replete – a standalone ClojureScript REPL for iOS by mfikes on Friday July 10, 2015 @10:45AM (#9864213)
Replete doesn't yet support using external libraries, but since the analyzer/compiler is available, I don't see any conceptual barrier preventing bootstrapped environments from consuming libraries.

David Nolen spoke a bit about Cljs-in-Cljs at the end of his Om Next talk, given at EuroClojure a few weeks ago. It's on YouTube now.

Re:Replete – a standalone ClojureScript REPL for iOS by sgrove on Friday July 10, 2015 @11:03AM (#9864321)
Link to said video (cljs-in-cljs) - https://youtu.be/ByNs9TG30E8?t=31m43s (link starts at cljs-specific stuff)

Discussion on HN - https://news.ycombinator.com/item?id=9848602