why android is built on a VM (Dalvik)-ThrowExceptions

Exception or error:

I am curious to know what made google choose to develop android’s framework on java VM.

In the process of writing code for android for nearly 6 months now, I observed that running code on a VM in a resource limited platform is really slow. There is a lot of overhead involved. I know that java is portable etc etc, is it not possible at all to use native languages and get both performance and features offered by a VM ? For performance oriented applications one still ends up writing native code and wrap it with JNI,

So why did google choose this particular stack :

  1. Arm based core (understandable, ARM is the best for mobile devices)
  2. Linux (Open source)
  3. Java VM (My question)

EDIT : I know java – JVM runs on par with C++ applications on my server, but not on android.
With respect to android its not the case – As a matter of my experience, a C++ code wrapped with JNI runs far faster than java code (note I have even checked with exact same code from a static block in java) I will agree with your answer on any other platform.

How to solve:

The Dalvik VM uses its own bytecode, not Java bytecode. It’s designed to be very fast (relatively speaking). I think the “VM” part of its title is a bit of a red herring, as people tend to assume that it will be “slow” no matter what. You said it yourself, you’re working with a “resource-limited platform” — that’s likely your main cause of slow performance, much more so than the Dalvik VM.

Disclaimer: I am not an expert on Dalvik or Android in any way, shape, or form. However, it seems like people can tend to make a lot of assumptions about Android based on ideas like “it uses a VM” and “you write applications in Java”, without looking into the platform further than that.

See this video for more information than you probably ever wanted to know on the Dalvik VM Internals (from Google I/O 2008).

###

1) Java is, as far as I know, the most universally taught language in universities and even high schools/equivalent. It is used widely in the professional world and has a lot of codebase behind it to help ease developers into creating more quality apps, faster.

2) The overhead is not that great vs. native code, especially with well designed code that is JIT optimized and being monitored by an ever-more-well-designed-gc.

Really, I think these two reasons alone can justify why Java was chosen as the primary language to be supported on Android.

###

I think the key, is to not think about the Java VM in the same sense that you think of for Destkop or Server virtualization — they’re very different. At the most basic level, the Java VM (in this case Dalvik) is simply a translation layer between the bytecode generated by the “compiler” into native machine code. It is a virtual machine — but it doesn’t have the same overhead as say, running Ubuntu in VirtualBox.

###

Java applications have been proven(not always) to run just as quickly and smoothly as applications written in languages like c, c++, etc. See this reference, check out the PDFs. Many people say that java and the vm is slow without actually much proof or details – and this reference goes into some detail

Java is a widely known language and it’s easy to pick up. putting the android sdk and tools in the hands of all these people who know Java already allows the android market to have a great potential of supplying its users with a large quantity of applications.

disclaimer: i’m no expert on this matter, just my 2 cents

Leave a Reply

Your email address will not be published. Required fields are marked *