Monday, 12 December 2011

Clojure REPL Tip: Loading Scripts

Ever wanted to write a script once and then run it using the Clojure REPL for Android? I was recently asked about this via e-mail, and I thought it would be good to make a note of it here.

First, you will need to write your script and get it onto your phone in a world-readable location. Usually, the SD card should work out well enoughi, which is generally mounted at /sdcard. Therefore, if you transfer your script coolscript.clj to the SD card, it should show up at /sdcard/coolscript.clj.

Now, all you need is the load-file command. To run the script above, you would just enter:

(load-file "/sdcard/coolscript.clj")

Limitation

Note there is one important limitation to this approach. It does not change the path for which scripts are looked up. If your script requires searching for other files that define namespaces, it generally will not work. Adding directories to the search path is proposed feature that would be nice to add.

Behind the scenes

I have not abandoned the REPL. Since the Conj, I have been working on the REPL to help get some more feedback to the Clojure/dev team to improve Clojure on Android. At the Conj, I announced Neko, the Clojure/Android Toolkit. I have since updated it to be compatible with the latest versions of both Clojure and the Android SDK. I also now have a version of Clojure for Android that is compatible with the latest 1.4 developments.

Please stay tuned for more Clojure/Android news and a Clojure/conj wrap-up.

Friday, 18 February 2011

Clojure REPL for Android now in beta

Just a quick post to announce that my Clojure REPL is now officially in ‘beta’. This new release includes some key usability enhancements:

  • It is now possible to click on historical input and have it be inserted into the entry field.
  • If an exception occurs while processing input, the entry field text is retained.
  • Focus automatically shifts back to the entry field after evaluation.

This does not make entering new input any easier, but should nonetheless help make things more pleasant.

Of course, this release also includes the minor enhancements from the silent ‘alpha2’ release from yesterday:

  • Shorten the time from the end of the load animation to the display of the REPL
  • Removal of some dead or unusable code, including the clojure.inspector, clojure.java.browse, and clojure.java.javadoc namespaces
  • Add Clojure sources so the source macro now works
Download

The REPL is available via the Android Market and from Deep Blue Lambda.

Coming soon

I will be presenting the Clojure REPL at the Clojure Houston User Group (CHUG) meeting this coming Thursday, the 24th of February. I will post more details about this later. Join the mailing list for the latest information.

This weekend, I plan to publish the next post in the ‘Creating Android applications with Clojure’ series, which will focus on using ProGuard.

I am also planning to release all of the Clojure REPL source code in the next week or so.

In the meantime, I appreciate your feedback via twitter, e-mail, or by commenting below.

Tuesday, 15 February 2011

Clojure REPL for Android now available

My Clojure REPL is now available on the Android Market. For now, there really is not all that much to it, but it does show that the full power of the Clojure language, including dynamic compilation, is possible on the Android platform.

The one extra feature the REPL includes is an embedded VimClojure server. I added this to the REPL in order to speed up development. In the end, instead of disabling that code, I simply made it an option that can be toggled by the user.

I do plan to develop the application further. Some of my ideas for new features include:

  • Make it easier to use, especially if a hardware keyboard is unavailable
  • Add the ability to run scripts from files

I will be publishing my modified Clojure source soon. At that time, I will describe in detail some of the changes that I have made, as well as some of the challenges that remain.

Of course, I am also interested in any feedback from users. So, please feel free to leave a comment, tweet, or e-mail me.

UPDATE: If you do not have access to an Android device and want to try it out on the SDK, the Clojure REPL is now availble from Deep Blue Lambda.

Friday, 11 February 2011

Preview of Clojure REPL for Android

I have taken some time over the past week on getting a Clojure REPL running on Android. At this point, it is pretty close to being ready for an initial release. Once ready, it should be available from the Android Market. In the meantime, here are a couple of screen shots:

Animated loading screen The REPL in action

Stay tuned for more.