5 ms·
Replete – a standalone ClojureScript REPL for iOS
- rdrey 11y agoVery nice! I'm busy learning Lisp/Scheme/Racket via CS61AS online and was thinking how nice Lisps would work on Microsoft's TouchDevelop. Have you thought about building a similar UI?
- mfikes 11y agoA nice aspect of this is that it is making use of a new capability of ClojureScript to bootstrap itself. This means that it can run its own compiler from within JavaScript, thus making it easy to create ClojureScript REPLs in environments where it wasn't previously possible. So long as TouchDevelop runs a JavaScript engine of some sort, it should be feasible. (Replete is evaluating ClojureScript forms directly on the device from within JS, without going to a backend via the network.)
- kanaka 11y agoClojurescript.net is running an online version of the bootstrapped REPL. It works on at least some mobile devices I've checked.
- mfikes 11y agoAuthor here. Willing to answer questions.
- elbenshira 11y agoIf 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?
- karlmikko 11y agoYes 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.
- dustingetz 11y agohttps://github.com/swannodette/cljs-bootstrap https://github.com/swannodette/cljs-bootstrap https://github.com/clojure/clojurescript/wiki/Bootstrapping-the-Compiler https://github.com/clojure/clojurescript/wiki/Bootstrapping-...
- swannodette 11y agoOver 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/d1d3e8664406260e07b1549e803cb34b818ea983/src/main/clojure/cljs/core.cljc#L44-L50 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.
- kahunamoore 11y agoAwesome work David!
- 11y ago
- escherize 11y agoIs 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?
- mfikes 11y agoReplete 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.
- sgrove 11y agoLink to said video (cljs-in-cljs) - https://youtu.be/ByNs9TG30E8?t=31m43s https://youtu.be/ByNs9TG30E8?t=31m43s (link starts at cljs-specific stuff) Discussion on HN - https://news.ycombinator.com/item?id=9848602 https://news.ycombinator.com/item?id=9848602
- sctb 11y agohttps://news.ycombinator.com/item?id=9798158 https://news.ycombinator.com/item?id=9798158
- dang 11y agoSince this post is having a discussion and the previous one didn't, we've un-duped it.
- 616c 11y agoI have been wanting to learn Clojure for a while, but I am not an iOS guy. I do not want to take away mfikes' thunder (super solid and amazing work by the way, sir. Saw your blog post on earlier work on /r/clojure on reddit ... I think, maybe a week or two ago), but how viable is something similar on Android? I would LOVE to have something like on my Nexus 6 while in the park and outings with the family.
- mfikes 11y agoIt is _extremely_ viable: The core REPL functionality is based on a few ClojureScript lines from Joel Martin's initial work for something similar for Node. In short, to make an Android version would involve just running a JavaScript engine and hooking up a little bit of UI to send strings to it, and get strings back out of it. Replete is open source... feel free to steal heavily from it. Look at how simple and rough the first working version of Replete was (see demo of it at bottom of http://blog.fikesfarm.com/posts/2015-06-27-replete-a-standalone-ios-cljs-repl.html http://blog.fikesfarm.com/posts/2015-06-27-replete-a-standal...) IMHO an Android version is just waiting to be created by someone. :)
- 616c 11y agoVery cool. Very nice to see your work. Hope to learn something from you soon. Maybe I will steal a friend's iPad to play with your stuff. Will keep track of your stuff.
- mfikes 11y agoReplete is in beta right now, so it simply requires signing up and making use of TestFlight. https://github.com/mfikes/replete/wiki/Beta https://github.com/mfikes/replete/wiki/Beta Also, it is a slightly older version, but if you want, you can try it directly online here: https://appetize.io/app/8hf37bv29k2zrj0v2j765xt3jr https://appetize.io/app/8hf37bv29k2zrj0v2j765xt3jr
- mfikes 11y agoA bootstrapped ClojureScript REPL now exists for Android. Replicator: http://tahmid.me/posts/2015-07-15-bootstrapped-cljs-repl-for-android.html http://tahmid.me/posts/2015-07-15-bootstrapped-cljs-repl-for...
- idbehold 11y agoIs there anything like this for javascript? A REPL for iOS that is. I searched for one a few weeks ago and there was nothing as simple as this.