Friday, June 11, 2010

Android (particularly Froyo) Advantage Explained

And the resulting threat to the iPhone. Sam Pullara on his Java Rants blog discusses how Android's Java implementation is much improved with Froyo (Android 2.2) and the advantages it has over iPhone's Objective-C.

I'm also coming to understand more how much the garbage collector (GC in the quote below) and over-allocating data from the heap or failing to de-allocate (memory leaks) affects Android performance.  Chances are, if your Android phone seems slow or choppy, you're waiting for garbage collection.

Up until Android 2.2 (Froyo) the JVM (really a Dalvik JVM for licensing reasons) on the Android platform was playing with one hand tied behind its back. Different from desktop/server Java, the JVM was still an interpreter, like the original JVM back in the Java 1.0 days. It was very efficient interpreter but an interpreter none-the-less and was not creating native code from the Dalvik bytecodes that it uses. As of Android 2.2 they have added a JIT, a just-in-time compiler, to the stack that translates the Dalvik bytecode into much more efficient machine code much like a C/C++ compiler. You can see the results of this in the benchmarks of Froyo which show a 2-5x improvement. As they add more and more JIT and GC features that have appeared in HotSpot, JRockit, etc, you will likely see even more improvements over time — without having to change or recompile the 3rd party developed software.