Dalvik
~ the obit ~
For six years the applications on every Android phone in the world ran inside a virtual machine named after a fishing village of about 1,400 people on the north coast of Iceland. Dan Bornstein wrote it and named it Dalvik because his family had come from there. I knew that name for years before I knew that fact, which is roughly the correct order for a piece of infrastructure.
It shipped with Android 1.0 on 23 september 2008 and it existed because the obvious answer did not fit. A standard Java virtual machine is stack-based and expects a machine with room to breathe. The phones of 2008 had neither the memory nor the licensing situation for that, so Bornstein built a register-based machine instead, one that took fewer and larger instructions per operation. Alongside it came a tool called dx, which chewed compiled Java classes into a single.dex file where every string duplicated across the whole application was stored exactly once.
That last part sounds like an accounting detail and it was the entire point. A phone with 192 megabytes of RAM cannot afford to hold the same constant three hundred times because three hundred classes each mentioned it. Dalvik was an argument about memory pressure, written down as a bytecode format, and it was the right argument for the hardware it was aimed at.
It was also slow, and everybody knew it. There was no just-in-time compiler at all until Android 2.2 in 2010 added a trace-based one, and even afterward the runtime paid its interpretation cost on every launch of every application, forever, on a device with a battery. Google shipped an alternative called ART as an opt-in preview in Android 4.4 on 31 october 2013 and made it the default the following year. Android 5.0 Lollipop arrived on 12 november 2014 as the first release with no Dalvik in it at all.
~ the rap sheet ~
| Born | 23 september 2008, shipped with Android 1.0 |
|---|---|
| Peak | the runtime under every Android application, on a billion devices |
| Killed | 12 november 2014, Android 5.0 Lollipop shipped with ART as the only runtime |
| Lifespan | six years |
| Made by | Dan Bornstein at Google |
| Killed by | ART, and phones that could finally afford to compile at install time |
~ the trade it made ~
ART won by inverting one decision. Dalvik compiled bytecode to native instructions while the application was running, over and over, on every launch. ART compiles once at install time and keeps the result, so the phone does the work when you are already waiting for a progress bar rather than when you are trying to open something.
That trade was unavailable in 2008. Compiling at install costs installation time and a great deal of storage, and a device with a couple of gigabytes of flash could not spend it. By 2014 storage was cheap and processors were fast and the same trade was obviously correct. Dalvik was not replaced because it was badly built. It was replaced because the constraint it was designed around stopped existing, which is the most common way good infrastructure dies.
~ the lawsuit it dragged behind it ~
Dalvik is also the reason Oracle sued Google. The claim filed on 12 august 2010 was that Android's runtime infringed Java patents and that the class library copied the structure of Java's APIs. The patent side collapsed in 2012 when a jury found no infringement, and the copyright side went on for another decade before the Supreme Court found fair use in 2021.
The class library at issue mostly came from Apache Harmony, a project that had spent its whole life unable to get a compatibility license out of Sun and was retired in 2011. Google took the code anyway, since the Apache License permitted it and calling the result Java was never part of the plan, and so a class library nobody would certify ended up on more devices than any certified one.
~ what survived ~
The.dex format outlived the virtual machine that gave it a name. ART still reads dex and the build tools still produce it. The 65,536 method limit that every Android developer has cursed at is a consequence of a field width chosen for a phone that no longer exists. The interpreter is gone. Its file format is load-bearing.
The other inheritance is a habit of thinking. Dalvik was a case of somebody looking hard at a well-established solution and deciding the constraints had changed enough to justify rewriting the layer rather than tuning it. That decision is expensive and usually wrong. When it is right, the result runs on a billion devices and gets thrown away six years later by the same people, for the same reason.
~ leave a rose ~
an anonymous tribute. one rose per visitor per day.
@}-->-- ... roses left here
~ leave a wreath ~
a rose fades by morning. a wreath stays on this grave for good, with your name on it.
from $1, paid once through stripe. it keeps the graveyard running: the hosting and the nightly digging. adopt it and the headstone reads "maintained in memory by" you. the groundskeeper plants new wreaths at the next tending, usually within a day.
» one email a week: new graves and the anniversaries of the dead. subscribe
other software: [email protected], Fig, Yahoo! Go, Microsoft Dangerous Creatures
also died in 2010-2014: [email protected], Kangurum, Infoseek isweb Light
~ leave a note ~
visitors before you have left these graveside notes. anonymous welcome.