art-and-dalvik-e1383772650101

Google Is Looking To Replace Dalvik With ART; Here’s Why You Should Care

November 9, 2013 - Written By Jeremiah Nelson

Currently, Android apps run in something called the Dalvik. Dalvik is a process virtual machine, and you can read up on it here. It’s basically how Android apps run on our phones. It allows the same app to run on devices that have different processors and different amounts of RAM. Google has been working on a replacement for Dalvik called ART (Android Runtime) that will speed up apps and make our devices run more efficiently.

Android apps are written in Java and then compiled into bytecode. Bytecode allows developers to build one app and submit it to the Google Play Store or the app store of their choosing. The app can then be made available for a variety of devices. Those devices will run it in Dalvik. Every time you run an app on your smartphone, tablet, or other Android device, the bytecode for that program is sent to a compiler that makes it work. Dalvik uses the JIT – Just In Time – compiler. JIT translates the bytecode into specific machine code that can run on your device. All of that happens on the fly with JIT. That’s why it’s “Just In Time.”

In the new Android Runtime (ART), Google is going to make all of this happen even faster.

android_art_settings

Google has been working on ART for about two years. ART uses an Ahead Of Time (AOT) compiler instead of the JIT compiler used in Dalvik. An AOT compiler handles bytecode in a similar fashion to how a web browser pre-caches websites for faster loading. The AOT compiler will translate bytecode for an app into the appropriate machine code at the time that you download the app to your device. It doesn’t wait until you open the app to change the code to something your device can run. Handling apps this was can take up more device storage, but it will make apps open faster. They’ll also run much smoother.

The Android developer site has a short introduction to ART:

ART is a new Android runtime being introduced experimentally in the 4.4 release. This is a preview of work in progress in KitKat that can be turned on in Settings > developer options. This is available for the purpose of obtaining early developer and partner feedback.

Important: Dalvik must remain the default runtime or you risk breaking your Android implementations and third-party applications.

Two runtimes are now available, the existing Dalvik runtime (libdvm.so) and the ART (libart.so). A device can be built using either or both. (You can dual boot from Developer options if both are installed.)

In it’s current form, ART is an experimental option designed for devs and OEMs. Google wants to begin the transition to ART, and that starts with app developers and device manufacturers. The setting is not supposed to be used by everyone. That’s why it has to be enabled under Developer Options in your Android Settings. It can make apps crash and cause you some general unpleasantness, so be careful if you decide you want to play with it.

ART is going to bring some pretty significant performance enhancements to our Android devices. It won’t be available for everyone until at least the next version of Android is released, however. Dave Burke, the head of Android engineering, told ReadWrite:

“I don’t want to make promises but I imagine next release it could be ready. Maybe. We will switch over when it is ready. It is actually quite fast now and now we are just really optimizing it and assuming those optimizations go well I assume that we will be ready to switch over at the next opportunity. We are working actively on it and we will port over on it when we think it is better than Dalvik in every way.”

ART will be here when it’s ready, but it’s going to make our apps and devices run better. That’s always a good thing.