Android has been evolving at a fast pace, but one crucial component of the operating system did not undergo much changes in the last couple of years. The Dalvik run time(Dalvik – named after a fishing village in Iceland) that makes any android application run on our smartphones, tablets, TVs, wearables and other devices has been replaced by a new Runtime called ART, Android Runtime. For those who are not familiar with Runtime, it’s a piece of software that comes in between an application and an operating system that converts the byte code into machine instructions. Runtimes are what makes our source code portable across platforms, processors etc. To give an example, it’s the Java runtime that makes the java applications we write run on a Linux system as well as a windows system. ART was introduced as part of Android KitKat as an optional Run time. One can go to settings at Settings > Developer Options > Select Runtime and choose between Dalvik and ART. But with Lollipop Google has dumped Dalvik for good.
Dalvik worked on the principle of JIT, Just in time Compilation, where the java byte code in an android application gets converted into the machine code only during the execution time. So only that piece of code that is associated with the functionalities we use get compiled and the code that is associated with the functionalities we do not use, never gets compiled. Hence it has a smaller memory foot print and uses only less physical memory on the device. There was also a downside to this and that was performance. Every time some code has to be executed for the first time, it has to be Just in time compiled and then executed. This would make the app respond a little slower. There are also limitations on how much code optimization that can be performed at run time. For servers there is more leeway in terms of available memory and CPU power but on mobile you can only optimize so much without slowing things down with code optimization and JIT code generation overhead. We would have always envied our friends, when we see the same apps that run on our android phones behave more responsive on their iPhones. IOS devices do not use a run time and they are compiled to machine code before they are installed on the devices.
ART handles the Android application execution in a fundamentally different way as against Dalvik. ART would do an Ahead of time compilation at the time when the app gets installed on the device. This would make the installation process longer than before but since the byte code is already compiled to machine code, the performance would be significantly better than that of Dalvik. Thanks to ART, Android users do not have to envy the Apple users anymore. Since the app is getting compiled ahead of time there is no need for a run time during execution.
The main advantage of ART is that it makes the android apps run much faster and be more responsive. Some findings suggest that Apps are 100% faster on ART than on Dalvik. The elimination of JIT compilation makes it easy on the battery and our phones will run for longer duration. The move from Dalvik to ART has happened without affecting the developers and they can continue to write the apps in the same way they did for Dalvik.
- How can a mobile application lower your motor insurance premium and improve safety? - November 18, 2015
- Aspire’s Mobile CoE and it’s focus on Xamarin - October 15, 2015
- Dalvik to ART, Why a change of runtime in Android Lollipop? - January 30, 2015