Saturday, February 20, 2010

DroidScript - Live JavaScript on Android

I have spent the day with getting the DroidScript web based editor up and running. It is available here: http://droidscript.se (droidscript.org and droidscript.net will also work in the near future). The site has a QR-Code you can use for downloading and installing the app on your device.

The source code is on GitHub at http://github.com/divineprog/droidscript. The application consists of a core part written in Java, and the user interface which is written in JavaScript ("eat your own dog food!"). There are still many rough edges, but the project is great fun. I think this style of programming, directly on the device, has several benefits. It opens up for exploration, and incremental development. I envision that this style can be great fun for young people who want to learn to program on their Android device.

The JavaScript code of the app is in the droidscript directory on the sdcard. This means that you can edit these files and modify the program without having to install the Android SDK. Of course you can also write your own programs. Unfurtunately, it seems as if you cannot have the device connected and mounted via USB and at the same time have apps that access the sdcard. That would have been nice, because then you could have had the JavaScript code open in an editor on the computer and the program running while editing it. But the web based editor solve this problem.

The web based editor sends in requests to a tiny web server that is running on the device. It accepts PUT and GET requests with JavaScript as content. The code is evaluated by the Mozilla Rhino JavaScript engine, and the result is sent back to the web browser (including error messages). With this tool, it is possible to incrementally create the user interface and other components of a program. (I should make a YouTube video that shows how to do this!)

Next step is to implement missing parts and to make the app more stable and also to make error handling more roubust. Regarding other languages, besides JavaScript, it would be nice to make the interpreter pluggable. BeanShell, for example, would be rather easy to integrate into the program. Ruby would also be very nice to have.

2 comments:

  1. Fabulous! This may be the start of a new and better way to design mobile apps.

    ReplyDelete
  2. Cool stuff - I'm impressed as always.

    ReplyDelete