A Brief History of The Adobe Flex Compiler
Good evening. Let me start with telling a little bit about the history of the Flex compiler. When we first started building the Flex compiler back in 2002, we almost started everything from scratch. Well, one of the exceptions was the support for ActionScript 2. We ported the C++ version of the ActionScript 2 compiler written by the Flash Authoring team to Java. We then rolled our own Java-based SWF encoding/decoding library (back then we called it SWFKit… now I don’t know what is officially called) and then added a whole bunch of features like MXML, SWC and asset imports. It was quite an experience because we “glue” this version 1.0 compiler together from a bunch of codes we produced and grabbed from Authoring and other open source projects. The “borrowed” codes didn’t have well-defined integration points. Some of them needed refactorings. The resulting 1.x compiler was okay – we were proud of that but we all believed back then we could make it better in our second attempt.
That opportunity came in 2004. We were wrapping up the Flex 1.5 development but we were also busy planning on what to do in Flex 2. At that time, we knew we were going to have a brand-new VM and “compiler” for ActionScript 3 support (The Player team was in charge of building both). We were excited but worried – we needed to focus on wrapping up 1.5 but we also needed to set aside engineering time to review the new AS3 compiler design. Basically, we couldn’t afford to get a “black-box” AS3 compiler again. We needed the AS3 compiler to come in pieces with well-defined integration points. We needed the AS3 compiler pieces to fit right into our new Flex 2.0 compiler architecture.
Fortunately, we got what we wanted… but not without spending a couple of months to port the C++based AS3 compiler into Java and test the Java port against some several thousands SpiderMonkey tests! Well, this was hard work but without intimately involved in the porting work, we would not have been able to understand the design and recommend design changes.
We also rewrote and refactored most of the MXML parser and AS code generation. SWC was also redesigned and reimplemented to address scalability issues.
The compiler codebase that is now open source, although in version 3, is still based on the compiler architecture we designed in version 2. In version 3, we added features like cross-domain RSL support; static multi-language compilation; Adobe Font Engine support, etc.
IMHO, this is the result of the hard work done by the compiler team. Frankly, it is pretty amazing to see that a compiler can support multiple languages/text formats (.mxml, .as, .css, .properties) and do all these by seamlessly tracking dependencies automatically.
The story is obviously much longer than the above, but I want to spare you from continuing to read this boring stuff. My next post will talk about how to understand the compiler step-by-step.