Andrepl: The JavaScript Repl for Android

I’ve had the urge to play with some JS on the subway (offline), so I open-sourced a really simple (read-evaluate-print-loop) repl for Android phones. It’s basically eval() wrapped in a native Webview with CodeMirror on top. I call it Andrepl.

Here’s the source Code: Andrepl

Post-mortem

This app started out as a PhoneGap application. That worked very well and I was able to get an initial version out quite quickly. However, there were a few hangups:

  1. The backspace key wouldn’t delete code from the editor
  2. The git-push -> phonegap rebuild -> re-download the app -> retest the app cycle was painful

The backspace key wouldn’t delete code from the editor

It turns out, after the fact, that this was a problem with CodeMirror, not phonegap’s key-binding interoperability. That github issue might conclude that it’s a problem with the Android OS; however, an older (maybe customized, build) of Codemirror found in this codemirror-android project works fine.

Originally thinking it was a PhoneGap limitation, I scrapped the phonegap version and forked that codemirror-android project – going down the native android app route. I refactored/extended codemirror-android into Andrepl.

In hindsight, I should have just taken the codemirror.js version from codemirror-android and slapped it into the phonegap version and the app would have worked fine. However, dealing with the phonegap builder created an inefficient development process.

The phonegap build process is painful

The typical PhoneGap process involves signing up with them, installing their command-line-interface (CLI), then doing a git push of your code, and then taking one of the 3 routes:

  1. The quicker but didn’t work way: issue a rebuild of the android version via the CLI then use a QR code reader to install the app with the QR code that they output in the terminal. It’s awesome to see a huge QR code in the terminal but I couldn’t get the app to install properly (though it worked with method 2 below).
  2. Go on their build site and do a manual resync of the source code which triggers a rebuild of the app, then scan the online QR code to install the app (actually works).
  3. Use their Ripple emulator to test and edit in real-time. This was a pleasure to use for assessing the visuals and base functionality of the app, but I needed to test typing on the soft-keyboard of an actual android device; so this method reached its limit very quickly.

There are so many inefficiencies in this process (especially being forced to pick up your phone) that it’s clear you’d have to build post-commit git hooks and such just to expedite a few pain-points in this process.

In comparison, the native app route is a breeze in its development cycle. It takes a while to get the android sdk up and running along with Eclipse, but that’s a one time cost. Click Run to start your app as an android project in Eclipse (with your android phone hooked up via usb) and the app starts running with minimal effort.

Conclusion

There’s a bit of work remaining to make the repl feel both better and more usable. It was a fun, 1-day hack and I look forward to using it on the train.