An anecdote on runtimes
Monday, June 5, 2017 :: Tagged under: engineering plt. ⏰ 6 minutes.
Hey! Thanks for reading! Just a reminder that I wrote this some years ago, and may have much more complicated feelings about this topic than I did when I wrote it. Happy to elaborate, feel free to reach out to me! 😄
My first gig was working on Adobe AIR, a (comparably) little-loved app runtime that was ahead of its time; I'd argue its fate as a faded silhouette of its potential was, as with most products, due to People Issues and changes in the context, in this case related to Macromedia's acquisition that touched everything in the Flash family, and many of the same "world changed around us" issues that hit Windows Vista. But that's a deeper post for another time that I'm absolutely not qualified to write. Here, I just want to go into a cute engineering anecdote that tickled me.
Note that all the following is entirely from memory; this was also my first gig out of college and I'd only been coding about 2 years, so please take this as lightheartedly as I'm writing it!
This all happened, naturally, before Thoughts On Flash was published. There's a lot that's correct about that essay but the fact that anyone viewed its contents (and notable omissions) as anything but naked business tactics is a reminder to me why we can't have nice things.
The punchline, of course, is that ECMAScript Revision 4 never accepted by the browser vendors, By that time Adobe had already built it into their product and written things like GUI Toolkits around it. So Mozilla didn't incorporate Tamarin, and Adobe rebranded it as ActionScript 3 (AS3).
(reminder that this was much less fashionable before Node + NPM ate the world, before Angular/React, and when the person pushing it was Adobe instead of Facebook or GitHub).
The more popular option was to leverage Flash's cross-platform consistency and either author your app in the Flash Authoring tool or write an AS3 app.
Famous apps using Adobe AIR include Pandora, the League of Legends out-of-game client (where you could buy skins, chat with friends, etc.), You Need A Budget.
About the internals
The last prerequisite knowledge needed is to know a few things about how the Flash VMs achieved backward compatibility: every instance of the Flash Runtime had two VMs in it: one for AS2 and one for AS3. When it encountered a source file, it'd check which version the file was, then pass it off to one VM or the other.
Type annotations in AS3 were optional, so while the following code was valid:
var i = 40;
unlike previous versions of ECMAScript, you could write
var i : int = 40;
Given this, a few Adobe engineers found they could make the VM significantly faster if it had all the type annotations, so they set to work on a VM called AS3' ("AS3 prime") that would be yet another code path for a version to take.
Finally, the anecdote
When you have an AIR app on your desktop, how do you support all of this? Well, naturally, you have a copy of your three VMs for you Flash code: AS2, AS3, and AS3':
But remember, we have WebKit there too, since this is for web developers and we want to support those technologies.
But! What kind of Adobe product would have a web browsing experience without Flash? Supposed you were a developer who already have a Flash site; if you ran it in the WebKit mode, it should work as before, right? It'd be downright shameful for Adobe to ship this unless the WebKit bit worked the way Adobe wanted a web browser to work. So we embedded the Flash web browser plugin into the WebKit instance. And that plugin had another copy of the runtime, with three more VMs:
But! What does a web browser do when it runs into a PDF? Browsers have better answers to this now, but back in these days, they'd open whatever program or plugin you had installed. And Adobe has a plugin for that!
Also, did you know that you can embed Flash files in PDFs? And that that's a separate build of the Flash guts? Meaning you have:
So in the spirit of the old rhyme:
As I was going to St. Ives, I met a man with seven wives, Each wife had seven sacks, Each sack had seven cats, Each cat had seven kits: Kits, cats, sacks, and wives, How many were there going to St. Ives?
How many ActionScript VMs do you have in here? At least 9. Also, for a while, we were going to add a fourth, AS4 (or AS Next). I left in 2012, and it looks like that got cancelled in early 2013.
Other fun facts
AIR wasn't a tiny runtime (a couple dozen MB if I remember correctly); but almost all of its disk size came from embedding WebKit. This was also when WebKit powered Chrome (pre-Blink), so it was used by a larger share of people.
Flash Platform powered a lot more products than most people realize: even for the web browser case most people know, they're unaware there was an ActiveX version of the plugin, an NPAPI plugin, and a Pepper plugin.
On top of the plugin to render content in web browsers, there was also a Standalone player (an app you could run on your desktop), the External player (embeddable in other apps, this is what Flash CS used to preview a stuff in the program), AIR, APE (the little-known Adobe Platform for Embedding), the Acrobat plugin renderer.
Naturally these all had to work on Windows (XP, Vista, 7; win32 and winRT), Mac (OS X, but a surprising amount of OS 9 support was still there when I joined), Linux (LOL, but mostly Ubuntu), QNX (used mostly by RIM for a few failed devices; I love when people in suits make deals), Android (it was a differentiating feature!), iOS (wait, what? yeah kids, you can put AIR apps on iOS), and Samsung TV. These are just the ones I can remember 5 years later, I could be forgetting some and/or they could have added more.
👆🏼 Most of these had at least three of Firefox, IE, Safari, and Chrome. Each of those has various versions.
(I'll also note this is where I saw the most impressive inheritance graph and build files I've ever encountered)
Flash wasn't perfect, but it worked quite reliably on all of them. Good times 😄
If you take anything away from me mentioning Adobe time, I want to make something 1000% clear: Adobe is a fantastic company with brilliant, kind people and I can't have asked for a better first gig. Flash was an extremely impressive product and codebase; it was a real privilege getting to work on it.
[1.] This is absolutely not a security nightmare.↩
Thanks for the read! Disagreed? Violent agreement!? Feel free to join my mailing list, drop me a line at , or leave a comment below! I'd love to hear from you 😄