Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why android is built on a VM (Dalvik) [closed]

Tags:

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.

like image 398
srinathhs Avatar asked Dec 20 '10 16:12

srinathhs


People also ask

Why Dalvik VM is used in Android?

Dalvik Virtual Machine provides high-performance features, better memory management, and battery life for low-powered handheld devices. It was developed exclusively for android devices and allowed several apps to execute on the virtual machine.

Is Android still using Dalvik?

Dalvik is a discontinued process virtual machine (VM) in Android operating system that executes applications written for Android.

Which VM does Android use?

While Android applications are written in Java, Android uses its own virtual machine called Dalvik.

What was the main reason for replacing the Java VM with Dalvik?

One of the main reasons of using DVM in android is because it follows the register based model and it is much faster than stack based model while JVM follows the stack based model which takes a lot of memory and also slower than DVM.


1 Answers

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).

like image 179
Donut Avatar answered Sep 20 '22 08:09

Donut