Sunday, June 21, 2009

Dalvik, running java efficiently

The story of virtual machines is beginning to be quite long ; Smalltalk, Lisp, Java, dotNet, ... The idea behind these were to be able to write once and deploy everywhere. In the case of Smalltalk, it was even a step further by including the concept of "image" which is actually a kind of object oriented database.
The drawback of these approaches is mainly the lack of performance, even if many, many improvements has been made to ensure execution celerity (hotspot for instance)... But the constatation is in front of our eyes : eclipse is still a big processor and memory consummer, microsoft doesn't still write its main applications in dotNet, and so on...
One of the avantage of using VM is that the developper can develop quicker and safer (no more memory leaks for instance). We could easily continue to develop this way but by adding a compilation step we could ensure efficiency. It is what Excelsior proposes, but also IS2T with their Icetea technology.
Google followed the same way by providing the Dalvik technology, ie a VM running .dex files directly got from java .class files. This new format is shorter, quicker, more memory efficient but has not just-in-time compiler. This VM enables Google to run java programs on Android efficiently, and also not to pay fees to Sun ;)

1 comment:

Unknown said...

Well, I'd say that apart from being registers-based (vs. stack-based), the Dalvik VM is no match for the "official" JVM. I've never seen any benchmark showing a particular advantage.
Hotspot is one of the most, if not the most, optimized VM. Even Python or Ruby interpreter/jit perform well over it.
And will even more, thanks to invokedyamic.

On Android... hard to criticize a gift from google to the open source community, but why enforce an abstraction, reinventing the wheel, later release a native sdk (actually just a JNI bridge) instead of providing low-level access to known and mature solutions as Nokia and Intel do, with Maemo and Moblin respectively ?