RSS Feed

20 December 2007

Why there is nothing but Java for android



So, I've been thinking a bit more about Java and C on the Android phones, and the conclusion that I have come to seems to make sense to me, at least.


Google is using a walled garden strategy with regards to application security: each application gets its own virtual garden and virtual resources which it then uses. Applications can then make connections between walled gardens if they want to share data. I have written about this before.


This implementation is done in Java, because it makes sense to run a separate Java VM for each application. The phone is not viably going to be running more than the frontmost application at one time, and the background processes are probably going to be nice'd through the roof. This enables the frontmost app to be responsive to user stimulus, at least with a keyboard. This is a system that works fine in Java, but what if we add another programming language to the mix, such as C++ or Objective C. Without building its own virtual machine to run non-interperetted programs in and optimizing it all by its lonesome self, Google is using a language that already has an optimized interpreter, enabling it to do as little work as possible. This prevents Android apps from being written in any language but Java. Quite frankly, I'm surprised that Sun is not in on the open handset alliance. Probably because they are designing their own Java-only phone. Ooh, more competition in the market.


There is yet another problem with using Java in a device with a not-so-fast processor: if you need something constantly updated with quick redraws, like something using a 3D engine, it will be pretty slow. An example of this is the earth demo on the example android phone. The globe was lagging just enough to be annoying and seem too slow to be usable. Java generally is a very slow language, which is the cost of a very dynamic language. I like Objective C because it incorporates the right amount of dynamism and static typing for me to use effectively, plus the fact that it is really easy to use.

No comments: