Stuff I am building:


Ted Patrick - Events & Community @ Adobe Systems


Note: This is the personal blog of Ted Patrick. The opinions and statements voiced here are my own.



Extending Adobe Flash Player and Adobe AIR with C and C++ via ActionScript 3

DIGG IT!     31 Comments Published Tuesday, February 26, 2008 at 1:44 PM .

At MAX 2007 we showcased an internal project called "C/C++ to ActionScript Compiler" at the sneaks and Kevin Lynch mentioned the project at Engage 2008 yesterday. The project is a cross-compiler for ActionScript allowing any C or C++ code to run in Adobe Flash Player or Adobe AIR. The project has some interesting implications for extending Adobe's platform in terms of legacy code, programming languages, and other open source code libraries. The key is that many other programming languages are built atop C/C++ to be more specific:

Java, Python, Ruby, PHP, Lua, Perl, C# (Mono), JavaScript, and many more...

Part of this implementation includes a pattern in ActionScript that allows for "green threading" that supports executing synchronous code in the asynchronous ActionScript virtual machine. The work done here is quite groundbreaking and has highlighted quite a few performance improvements in the current virtual machine while expanding the capability of the platform.

Like many organizations Adobe has lots of legacy C/C++ code ranging from PhotoShop filters, to PDF renderers, to readers and writers of every file format in existence, font libraries, to very complex vector renderers, and text layout code. Beyond Adobe there are many open source libraries that could be leveraged as components as well. The big thing for me is that these are not ports of these libraries, they run identical to the original source code down. For example the behavior of Python in Flash Player is identical to C-Python vs the ported behavior under the IronPython and Jython projects. The goal here is to bring lots of these legacy assets, code libraries, and languages into Flash Player and Adobe AIR perfectly so that any developer can leverage them cross-platform to build software. It would not shock me to see some of these components added into the Flash Player component cache so that they essentially are built into the player on first use.


As an example of the complexity of this project, the engineers ported the C++ version of Quake 1 engine into Flash Player and it worked perfectly and performed well. It is an extreme case but showcased the potential of this project.

To set expectations this project is Adobe internal at this time. It will be interesting to watch how this evolves over time and how much richer Adobe Flash Player and Adobe AIR become as software platforms. We are working on some game changing things, stay tuned!

Cheers,

Ted :)

31 Responses to “Extending Adobe Flash Player and Adobe AIR with C and C++ via ActionScript 3”

  1. # OpenID funkyboy

    looking forward...  

  2. # Blogger SoJ

    Whoa.

    Are you saying that I could potentially write a socket server or P2P client that runs on AIR?  

  3. # Blogger katopz

    Python in Flash Player.....:O  

  4. # Blogger XIX

    Java, Python, Ruby, PHP, Lua, Perl, C# (Mono), JavaScript, and many more...

    AND

    More importantly AS2

    So, where for is the AS2 machine compiled in AS3?

    I'm guessing you guys have the source for that one :)

    You know failing to fully support legacy programming languages is something that Microsoft does. You're not just like them are you?  

  5. # OpenID chirayu

    Very impressive if pure C/C++ actually compiles and works with reasonable performance.  

  6. # Anonymous German Bauer

    Ted, doesn't this platform-specifity kill the whole idea of cross-platform-ness, because now it is not entirely clear what dependencies are to external platform-specifc libraries. I thought that was one of the biggest advantages of Actionscript, write once (mostly) works anywhere AS is (mostly).

    I realize Adobe probably wants to use it to decouple front- from backend development, but it feels dangerously close to a defragmentation of the whole Flash platform  

  7. # Blogger Dhaya

    I think my heart skipped a beat when I read this post. Thanks to Adobe, the 21st century will be excellent for developpers.  

  8. # Anonymous Oliver

    I guess it's Quake I not III  

  9. # Anonymous Anonymous

    Quake 3 or 1?  

  10. # Blogger Ria Flex

    Or WebKit in the Flash player so I can stop developing my own xhtml renderer for Flex...  

  11. # Anonymous Gabriele Farina

    It seems interesting. I saw the video of Quake 3 running on the flash player and it was really smooth.
    The tools are able to compile targetting the actual flash player or the new one ?
    Or do them simply translate code to AS3 ?  

  12. # Blogger zwetan

    very interesting :)

    but what about a small C/C++ lib or command-line tool which need to use a specific system access that flash or AIR can't access ?

    ok it's internal, you can't give use details ..ok

    is this tool would ever become non-internal :) ?  

  13. # Blogger Jeremyx

    Would the source C code need to be pure C -- free of framework calls and OS specifics?  

  14. # Blogger Ted Patrick

    The engine was Quake 1. Post has been corrected.

    Ted  

  15. # Anonymous Bill Shirley

    Supporting gcc's Objective-C?  

  16. # Blogger Herschel

    In the videos, code like this can be seen:

    var xslPtr:int = __allocString( xsl.toString() );
    var resPtr:int = __call(machineC, xmlPtr, 0 );
    var retStr:String = __stringFromMem( resPtr );

    For one, this makes it seem like the legacy code is 'embedded' into the Flash file, instead of truly cross compiled. Does this technology actually compile C down to AVM2 bytecode? It'd be great to have this elaborated on. :)

    Also, these are quite low level calls. Manipulating pointers like this seems pretty unsafe. This seems opposed to Flash's traditionally strict security policies! :) -- not to mention other's concerns about platform dependence.

    In any case, this is exciting, albeit odd, step for Adobe. :) I look forward to see what comes from it!  

  17. # Anonymous Hussam

    Wow !! This is amazing!  

  18. # Blogger Olivier Groulx

    I'm not sure but it kinda looks like Director's Xtras... no?  

  19. # Blogger sergo

    I wanna see the VIDEO!
    I cant imagine it, and hard to believe it. What about Performance?
    You do a revolution...  

  20. # Blogger Beau Scott

    This is really cool! But the real question is: WHERE CAN I FIND THAT .AIR PACKAGE?! ;) And can you compile it with the grapple hook mod?

    Beau  

  21. # Anonymous Anonymous

    Don't get excited too quickly, remember these comments may be searched in 20 years and you can make people laugh by your pre-mature excitations (remember the 80s?).

    Right now a simple youtube video player in flash is a bloody cpu eater in linux, never mind porting quake and playing it in flash under linux.

    The problem of flash player high cpu waste has been around for ever and clearly adobe is only loyal to m$.  

  22. # Anonymous Anonymous

    That is all great, but in the mean time I have a bunch of Java code running on the server that I would like to leverage on the client without running a localy hosted java server. Is there any way to load java libraries from AIR. I don't want to have to port my Java code to AS so I can run it in the client, that would be nuts!.  

  23. # Blogger Ghaladen

    Sounds great, but for example what if I wanted to write an app in Java, but I wanted to make calls to an ActionScript library such as Away3D or Papervision, will this be possible?  

  24. # Anonymous rob

    agree with XIX

    where is the compatibility for AS2 under AIR?

    i'd love to use AIR as a more powerful / stable desktop projector, using some online data , for apps that need it .... but don't think i can .... without porting lots of code from AS2 to AS3?

    no efficiencies there ...  

  25. # Anonymous Alex Griffin

    Very impressive if pure C/C++ actually compiles and works with reasonable performance.  

  26. # Anonymous Karl Kiss

    Very impressive if pure C/C++ actually compiles and works with reasonable performance.  

  27. # Anonymous Peter Szabo

    Or WebKit in the Flash player so I can stop developing my own xhtml renderer for Flex...  

  28. # Blogger george tomas

    Wow, this seems really interesting and could potentially boost the size of the AS3/Flex/Air developers community.  

  29. # Anonymous george tomas

    Very impressive if pure C/C++ actually compiles and works with reasonable performance.  

  30. # Anonymous Anonymous

    Any update on this?  

  31. # Blogger Jeremyx

    It's a project called Alchemy on Labs now...http://labs.adobe.com/technologies/alchemy/  

Post a Comment

Where to find me:

Ted on Twitter - @AdobeTed
Ted on Adobe Groups
Ted on LinkedIn
Ted on Facebook
Ted at Adobe


Latest

Lists

Links

Jobs

Flex Jobs
city, state, zip

Archives