Jump to content

Which Virtual Machine on a Mobile platform is fastest?

MikeH's Photo
Posted Dec 10 2009 08:37 AM
3832 Views

So if you want your mobile app to be really fast, do you have to go low-level to the VM to improve performance? But do you think the VMs in Android and WebOS are as fast as iPhone's VM? Anyone have any benchmarks or thoughts on the fastest VM for Mobile?

Tags:
3 Subscribe


3 Replies

+ 2
  Maximiliano Firtman's Photo
Posted Dec 10 2009 02:02 PM

There are a lot of virtual machines, and the same virtual machines run on multiple hardware. It's not fair to compare VMs from different platforms or running in different hardware. For example, you can compare the Java ME VM of the Nokia N97 vs. the new Java VE VM 2.0 for the same device (available in betalabs.nokia.com). That will be a fair comparison. But Android vs. Palm is like a different thing. Different hardware, different bytecode.

iPhone is not using a Virtual Machine. The compiled code is executed directly and it's not translated by a VM.

You will find VMs in Windows Mobile (Java ME and/or .NET), all Java ME compatible handsets, Android (Dalvik VM), the Flash Lite player.
Maximiliano Firtman
O'Reilly Author
ARFUG Manager - Adobe User Group
Forum Nokia Champion
firt.mobi / @firt
 : Dec 14 2009 10:25 AM
Well, Objective-C is supposed to have a thin runtime that it runs on, which I would think classifies as a virtual machine (albeit a minimal one that's included with each executable generated). The wikipedia article covers this minimally (http://en.wikipedia.org/wiki/Objective-C#Analysis_of_the_language).

In general, the iphone supports C, C++ and Objective-C, which are all compiled. You could design an app primarily in javascript by utilizing a browser object and utilizing DOM+JS for most of your app, in which case you would be utilizing the Javascript VM. Since the other systems you mentioned also provide the capability to code mostly in JS, some comparisons could be made based on the JS virtual machines used in each. Besides JS, none of the systems you mentioned have much in common in how they allow applications to be run. Apple allows native applications in C/C++/Obj-C, Android allows Dalvik (modified Java) bytecode and native libraries to be loaded by it (you can write a native app, but would have no access to the Android API, and the underlying video API is non-standard, although documented and open-sourced), and WebOS only allows HTML/CSS/JS development currently (AFAIK).
+ 1
  zigurd's Photo
Posted Dec 15 2009 02:21 PM

Compiled code, such as Objective C, benchmarks the fastest for computation. But, subjectively, Android and iPhone apps perform comparably. The reason is much of the heavy lifting in Android is in libraries like SGL and SQLite that are compiled. Both the Objective C runtime and Dalvik, the Java runtime in Android, have garbage collecting memory allocation, so memory allocation, too, will yield comparable performance.

The main difference in performance is in interpreted Java code on Android versus compiled Objective C, but, in most applications, intensive computation is rare, and this difference hardly ever becomes noticeable. Android's approach for applications that need to do significant computation is to enable calling compiled C code through JNIs. Applications developed using the "NDK" extension to the SDK can include compiled C code.

VM performance is therefore mostly factored out of what affects the user experience on Android.

But why not have a just-in-time (JIT) compiler on Android, just like the Sun Java VM? It could only help, right? The problem with that is that compilation involves a lot of computation, and that costs battery life. So Dalvik is, for now, an interpreter.