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.
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.
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:
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.
This is fun to watch and thought provoking. Perhaps swarm-based robotics has something to offer after all. Watch as the ReefScouts take off like a group of dolphins and then sink to the bottom like a [ ... ]