November 19th, 2008


Alchemy: Compile C/C++ straight to the Flash virtual machine.

Alchemy is a research project that allows users to compile C and C++ code that is targeted to run on the open source ActionScript Virtual Machine (AVM2). The purpose of this preview is to assess the level of community interest in reusing existing C and C++ libraries in Web applications that run on Adobe® Flash® Player and Adobe AIR®.

With Alchemy, Web application developers can now reuse hundreds of millions of lines of existing open source C and C++ client or server-side code on the Flash Platform. Alchemy brings the power of high performance C and C++ libraries to Web applications with minimal degradation on AVM2. The C/C++ code is compiled to ActionScript 3.0 as a SWF or SWC that runs on Adobe Flash Player 10 or Adobe AIR 1.5.

If you want more information on how the project actually works, it's built on LLVM, and at this years LLVM developers' meeting there was an extensive talk over the project with a few impressive demos (ex. unmodified quake source, running on the flash player at ~30fps, and playing zelda with flash using a C-written NES emulator.)

The talk also speaks about writing Flash applications in Python and Lua, since with Alchemy you can now compile Python/Lua directly to the AVM (and he has a demo of writing Flash stuff with Python.)

The talk is extremely interesting and informative (especially how they convert synchronous C code to asynchronous AS3 code using state machines.) You can find the slides and video here (last talk on the page):