Friday, October 5, 2007

C++ to ActionScript

One of the sneak peeks at Adobe MAX 2007 Chicago was a C++ to ActionScript translator by Scott Peterson. This was the most interesting of the sneak peeks for me in part because I was a C++ developer for 12 years (until 3 weeks ago) and because of the implications of the translator.

First check out the video here:

During the demo he showed:
  • A C++ XSLT library turned into ActionScript
  • A fractal program from C++ to ActionScript simulating green threads using ActionScripts asyncronous calls.
  • Doom 2 running in Flash.
How does it work:
  1. C/C++ code is translated to ActionScript 3
  2. AS3 code is compiled into a SWF
  3. Run the code on Flash/AIR

What does it mean:
  • Easy porting useful open source C++ libraries/programs to ActionScript to run on the browser.
  • Porting interpreters for languges like Ruby, PHP, Lua, Python, Smalltalk. ... to run on Flash.
  • Writing your own DSL using ANTLR and porting the C code to ActionScript without having to write an ANTLR target language. I recently wrote a shunting yard algorithm Lexer and RPN parser in ActionScript for an Excel like language where this would have saved me some time (but not the fun of writing my own Lexer/Parser).
Scott Peterson, if you ever read this and want an alpha/beta tester I have two projects in mind:


  1. it was quake not doom

  2. Yeah, this is quite important and should be stressed. Doom uses a much less complicated and CPU-intensive engine than Quake. It's a stunning feat that he was able to do it.