ClojureScript on Android
Over the past few days, I had one of the most rewarding experiences in my development career, and I wanted to share the story.
Recently, I had done some work to create an iOS ClojureScript REPL app, Replete. This is all cool, but an Android equivalent was just begging to be created. Unfortunately, my Android fu had become so weak, I couldn't take it on.
But, Tahmid Sadik stepped up to the plate.
:none mode), defining
CLOSURE_IMPORT_SCRIPT as needed, etc. It is important to have the runtime in this mode when you plan on having a REPL involved. It also opens the door for allowing you to
require source-defined namespaces in your REPL.
In fact, Replete needed to do the same, and it accomplished this using a feature of Ambly. Yes, I know, Replete is a standalone REPL and doesn't need Ambly. But I cheated and reused that capability, just to get ClojureScript up and running inside Replete.
As an aside, I had originally planned on building Replete using React Native. It turns out that using ClojureScript support for React Native, which is early days, and bootstrapped ClojureScript, which is early days, was just too much to take on while also succeeding in getting things actually working. So, for Replete, I fell back to keeping things simple, choosing to not even involve Goby.
A nice consequence of the above is that there were no React Native dependencies (which don't yet publicly exist for Android), nor Goby dependencies (which only targets iOS). The simplicity of bootstrapped ClojureScript inside Replete, working with a "conventional" iOS UI proved to be very useful in helping Tahmid accomplish the same on Android.
After getting through this, he was able to bring up ClosureScript.
cljs.core.apply.call(null,cljs.core.inc,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, , null))
(apply inc )
And Tahmid got back
2.0. Woot! I think this may have been a first. ClojureScript running in embedded Rhino on Android.
read-eval-print function, passing in the string
(+ 1 2). If that worked, then, bootstrapped ClojureScript baby!
replete.core.read_eval_print.call(null,'(+ 1 2)')
But… no dice. A call to
goog.require('replete.core'); caused something funky to derail in Transit related to
randomUUID. Dang! As these things go sometimes, more stuff evidently needed to be addressed.
println could work), and Tahmid announced to me via Slack:
I got 3 (+ 1 2) = 3
... explitives on my end, inappropriate for a blog post. A bootstrapped ClojureScript REPL was just born on Android!
What a blast!
The above is on a Nexus 5 device. I think it shows the true promise of ClojureScript with respect to reducing computational latency on mobile devices. I think it is time for ClojureScript to come alive for use in developing apps targeting mobile devices!
Update Sept. 30, 2015: Corrected to indicate that Vladimir Iakovlev's Bocko tests are done on an actual Nexus 5 device (and not a simulator).