There was a time when Microsoft's .NET Framework was only for desktops. Thanks to the efforts of Novell, .NET is now also a viable development platform for mobile environments as well.
Novell develops the Mono framework, which is an open source implementation of Microsoft's .NET. Novell had previously ported Mono to Apple iOS devices with MonoTouch and is now expanding the effort with Mono for Android.
"Porting Mono to Android was a relatively simple task, probably a couple of weeks worth of work," Miguel de Icaza, VP, developer platforms at Novell told InternetNews.com. "But a simple port of Mono to the Android device is not very useful on its own, as it would merely give access to the standard .NET libraries, and not have any features to use the host operating system."
De Icaza noted that the majority of his team's development time was spent on creating a binding that allowed C# developers to consume the native Java APIs. Additionally, time was spent developing the tooling necessary to use Visual Studio on Windows and MonoDevelop on Mac to provide the end-to-end development pipeline.
Challenges of Supporting Dalvik and Mono VMs
The Mono for Android development team also faced the development challenge of trying to get two garbage collectors to work in unison. De Icaza noted that the issue is usually referred to as the distributed garbage collection problem.
"We switched Mono's garbage collector to our in-house SGen garbage collector, and we added hooks that would let us solve the problem of distributed garbage collection between Dalvik and Mono's VM," De Icaza said.
Dalvik is the processor virtual machine in Google Android. De Icaza explained that C# code runs on top of the Mono VM and the Mono VM is sharing the address space with the Dalvik VM.
"This allows C# code running on Mono to call into the existing code in the Dalvik VM," De Icaza said. "This is important because all of the UI elements, device-specific APIs, audio, GPS and other APIs are only exposed in Android as Java/Dalvik APIs."
Mono for Android and MonoTouch
As to why Novell targeted Apple iOS ahead of Android, De Icaza noted that back when his team started with MonoTouch, Android was not very successful yet. He added that back in 2009 when MonoTouch first shipped the iPhone was already a tremendous success.
"We had to work 16-hour days including weekends just to ship the first MonoTouch to the public," De Icaza said. "We could not have done the two platforms at once."
Both MonoTouch and Mono for Android will share the Mono 2.10 runtime, so for anything in the shared code base, they will both gain the same benefits.
"There are a few slight differences on what iOS and what Android supports, so those limitations will continue to exist on each port," De Icaza said.
For example, he noted that Android does not allow dynamic classes to extend Java code, and iOS does not allow dynamic code generation. Additionally, Mono for Android and MonoTouch each has a different set of device-specific APIs.
"The approach we took was to give every bit of native functionality to developers on each platform," De Icaza said. "In the long term, we will contribute to the open source efforts that are creating abstraction layers for some of the most commonly requested features like a unified set of APIs for accessing the GPS, accelerometers, audio devices and so on."
"But until then, they will continue to have its own set of APIs," De Icaza added.