Every Android user is installing and running apps, surely without even knowing about Dalvik. But its importance is such that our phones would be useless without it.

So what is Dalvik? This pretty fishermen village along Iceland coasts? For sure! But it’s also a Virtual Machine at the heart of Android on which every application is executed by the Operating System. And it’s about to be replaced by ART (Android RunTime).

A Virtual Machine? What for?

The need for an additional software layer between the system (being Linux in Android’s case) and the app is that mobile devices running Android are manufactured by different vendors and all have different hardware architectures (understand processors, memories, …), which make it impossible for a developer to know in advance the type of hardware you’ll be using to run his app. Therefore, without a Virtual Machine in Android, developers would be unable to deliver apps for all Android smartphones and would be restricted to a given type of mobile devices (or even a single device!). Not very efficient…

So Google has developed an additional software layer that goes on top of Linux and abstracts all specific sides of a mobile device and in which apps are run: apps only see Virtual Machines… which are all the same in the Android world: Dalvik!

 

How Dalvik is working

Dalvik uses Linux services (security, thread management, memory management, …) to offer consistent high-level services to apps. It runs a particular kind of executable files made from Java classes, called .dex (Dalvik Executable) that are built by tools from Android Software Development Kit and made by app developers. Because mobile devices usually have little memory and processing capabilities, dex files are optimized to offer a low memory footprint and run faster (for geeks: Java Virtual Machines use a technology based on heaps, whereas Dalvik uses registers, that require much less processing for the same operations).

At run time, when Dalvik is running your favorite app on your particular device, content from dex files (also called ‘bytecode’) is transcoded on-the-fly from code that is generic to all devices to code that is specific to your device: this is JIT (aka Just In Time) compiling. This transformation is done every time your apps is run.

 

So why not do the job only once?

This is one of the reasons that have led Google to replace Dalvik. But the main one is that there’s a technology that can help do the job once while improving significantly user experience: at installation, the app is compiled once for your device, and will run specific code at all times it’s run! This is called AOT (Ahead Of Time), and brings significant performance improvements as it will highly contribute to make Dalvik's successor, ART, run twice as fast.

Of course, it also has drawbacks, like a bigger amount of memory required to store the app, and more time will be needed to install an app. But these are not the things that matter most to all of us, and what we want is fast apps with smooth and elegant interfaces.

 

I can’t wait to get this great feature!

And you’re right! Even if it is available since months in Android KitKat (4.4) as an option (somehow hidden in Developer Options menu), this new and innovative way to manage apps and improve user experience will be delivered as a standard feature in Android L (the next Android version to be delivered, most likely 5.0). For advanced techies, it is already available in developer version on Nexus devices (5 and 7), as it’s been announced at the Google I/O conference in June.

However, no official release date has been disclosed to have Android L benefit to all of us. But Google’s great rival, Apple, will be releasing its new iOS version pretty soon, so there’s a high chance Android L gets released in the coming months, all the more so as Android 4.4 major version dates back to October 2013.

 

So Dalvik is (almost) dead, long live ART!