Mono Ports Android to C#
Written by Mike James   
Friday, 04 May 2012

Would Google have been better off adopting C# as the basis for the Android operating system's development language and .NET for its runtime? The Mono team decided to find out with a little experiment. They did a conversion.

 

androidnet

 

 

Before you start to imagine the number of man hours it would take to convert the Android system to C#, it is worth saying that this was an automatic port.

Notice also that the Linux code that forms the bulk of the operating system wasn't involved. This is purely a port of the Java sub-systems to C#. The translation used Sharpen, an Eclipse plugin that translates a Java project to C#, and in this case it was faced with over a million lines of Java code to convert.

The project, called XobotOS, allowed the converted code to run on Mono's VM rather that the Dalvik VM built into Android. It seems that the basic assumption that the .NET VM would be faster than the relatively young Dalvik VM was proved correct.

 

monovdalvik

 

You can download XobotOS and the improved Sharpen tool from GitHub.

So would Google have been better going with .NET than Java? It is generally assumed that .NET is a more "dangerous" environment from the point of view of lawsuits than Java, but as Miguel de Icaza points out in the blog entry:

Unlike Sun with Java, Microsoft submitted C# and the .NET VM for standardization to ECMA and saw those standards graduated all the way to ISO strong patent commitments. The .NET framework is also covered by Microsoft’s legally binding community promise.

However, many in the open source community are very suspicious of the "community promise" which doesn't give away any patent rights. Many fear that if any project used .NET technology to good effect then Microsoft would reconsider its position and want a slice of the cake. As it turns out, Google was no better off going with Java and facing off against Oracle.

One interesting point is that with Microsoft's increasing preference for C++ and non-managed code, there is real possibility that it really doesn't care how .NET is used in other systems. As it is, Mono is rapidly becoming the only champion that the wider .NET technology has left.

Will we see a packaged and polished version of XobotOS, perhaps as part of Mono's offering for Android? 

This seems unlikely as it would require a complete change or addition to a phone's system software. Even if it is faster and results in less battery drain, the idea of making a change as big as Java to C# is a big undertaking. Some of the code may well make its way into Mono for Android and iOS.

As Miguel de Icaza says:

"A project that we started because we thought it would be fun to do has turned out to yield some serious benefits for our products. It’s important for a startup to stay focused, but sometimes you have to try something crazy to make progress. And who knows, maybe Google will thank us some day"

The final question is to do with copyright and patents. If Google loses the lawsuit, and Oracle ends up owning the copyright on the Java APIs and source code, how does this affect a C# version which was simply obtained by compiling the original Android Java to C#? I'm not a lawyer but somehow I don't think you can avoid the problems by simply re-compiling the code. If a clean room re-implementation doesn't get you off the hook, neither does recompiling the original code. So I doubt Miguel will be hearing from Google soon, but a call from Oracle seems all too likely.

 

androidnet

 

More Information

XobotOS available on github

Sharpen on github

Xamarin blog

Related Articles

Open Source XNA for Windows 8 Metro

The War At Microsoft - Managed v Unmanaged

Xamarin's first Mono release

 

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

 

To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+, Twitter, Linkedin or Facebook or sign up for our weekly newsletter.

 

Banner


Google Releases Gemma Open Models
28/02/2024

Google has released a set of lightweight open models that have been built from the same research and technology used to create Google's recent Gemini models.



Crazy Clocks
10/03/2024

It's that time again when the clocks change and  time is of the essence and I indulge my interest in crazy clocks. I am always surprised that there are still new ideas for how to display the time [ ... ]


More News

Last Updated ( Friday, 04 May 2012 )