MonoDroid: IronPython on Android?

MonoTouch is a cross-compiler IDE and toolchain for the iPhone OS series. It allows you to write iPhone / iPod Touch / iPad applications with .NET languages like C# and take advantage of nice features of the .NET framework (actually Mono) like the extensive class libraries, proper garbage collection and so on.

Because of the rules against interpreters and code generators MonoTouch didn't include the System.Reflection.Emit apis that are needed for Dynamic Language Runtime languages like IronPython and IronRuby. Despite this restriction  MonoTouch was a victim of the controversial Section 3.3.1 of the iPhone developer agreement that requires iPhone apps to be written in objective-C, C or C++. (Modern developers who prefer the reliability of garbage collection based languages need not apply...)

Apple's main goal seems to be sticking two fingers up to Adobe and banning their Flash cross compiler, but other tools like MonoTouch are collateral damage. If there was ever any doubt about whether you could write iPhone apps in Python (Python and objective-C are both running fine on jailbroken iPhones) that question has been decisively answered. The Adobe Flash cross-compiler does introduce an intermediate layer between your application and the device - the UI won't look and feel native and using any new APIs introduced in OS updates will be dependent on Adobe updating the tool. This is the reason that has been cited as the motivating factor for section 3.3.1. Although MonoTouch has a "runtime" providing some of the .NET features you still compile directly against the iPhone OS APIs: your UI can be native and there is no intermediate layer. Despite section 3.3.1 MonoTouch is still allowed for companies distributing internal apps and not using the app store (something that became possible in a recent OS update), but it's use is now doubtful for general app creation.

Fortunately the iPhone isn't the only game in town, you may possibly have heard of the google mobile OS called Android. Novell, the folks behind Mono and MonoTouch, have been creating an equivalent tool for Android and Miguel de Icaza announced it in a recent blog entry:

We are hard at work on MonoDroid -- Mono for Android -- and we have created a survey that will help us prioritize our tooling story and our binding story.
Most interesting is their feature list:

  Here is what you can expect from Mono on Android:
  • C#-ified bindings to the Android APIs.
  • Full JIT compiler: this means full LINQ, dynamic, and support for the Dynamic Language Runtime (IronPython, IronRuby and others).
  • Linker tools to ship only the bits that you need from Mono.
  • Ahead-of-Time compilation on install: when you install a Monodroid application, you can have Mono precompile the code to avoid any startup performance hit from your application. 
So, it looks like it will "soon" be possible to write applications for Android using IronPython - great!


  1. For Python developers, I'm not sure what this gives over and above CPython on android in the ASE - it will still have to use RPC to access the java based APIs. There was an attempt to port Jython to Android, but I believe this was abandoned as Dalvik (Android's JVM) did not do JIT compilation. Now there's a JIT in Android 2.2, maybe that will be revisited.

  2. I doubt MonoDroid uses RPC to call the Java based APIs - I *expect* that instead it compiles to Dalvik bytecode and calls them directly.

    ASE is not a way of writing full applications but a scripting environment instead. Running CPython natively on Android would be interesting, but you then still have to have a way of calling the APIs. IronPython compiled by MonoDroid sounds like a great way to bridge that gap.


Post a Comment

Popular posts from this blog

Extending Abobe Flash Player and AIR with Python and Ruby

Should Python Projects Support IronPython and Jython?

Further Adventures of the Debugger