Adobe Alchemy - C++ code running in Flash

This is not directly related to Java, but Adobe labs just announced a preview release of Alchemy, which lets C and C++ libraries run to support AS3 in the Flash player. A while back there was talk that something similar was in the works for getting Java code on the AVM2, which is why I figured I’d post about it here.

The link: http://labs.adobe.com/technologies/alchemy/

It will be interesting to see how this compares to JNI - it looks like you’re not running truly native code, as there’s still a significant speed penalty, but I imagine the performance is still better than for pure AS3. In any case, it does look a bit simpler than JNI, at least at a glance, so it may be worth keeping an eye on.

Edit: ah, so the internals of this are based on LLVM, which I believe we discussed here a little earlier. It would be fairly straightforward to add a Java source (or target, for that matter) to this if there was interest.

Ditto, it would definitely be a really useful approach.

Kev

It appears that the expected speed is up to ten times faster than hand coded AS3, and between 2 and 10x as slow as native C++, which would put it somewhat close to Java territory, though not quite (I tend to see between 25% and about 75% of C++ performance in Java for general algorithms, i.e. ones that aren’t specifically selected to play to the strengths of one language or the other).

It would be very interesting to see how Java would run in Flash when compiled in this way; it’s not a panacea to the deployment issues that we’ve been discussing to death lately, because it wouldn’t cover things like graphics and I/O, but IIRC there actually is some work being done on threading support (not sure if it’s active or not right now), and for libraries it could be a decent solution.

We (well, “we” as in probably not me, because I’m too busy at the moment, but someone) are probably going to play around with getting Box2d (the C++ version) running using this tool to see how it compares to the manual AS3 port, the Java version, and the C++ one - that’s a pretty reasonable test, as the C++ library is independent of most external stuff, and it hasn’t been designed specifically to show off this tool. I’ll post a note here if we see anything interesting.

Isn’t there an enormous security risk with this? SWF files don’t require signing at all…

no no - its just as secure as fullscreen flash (fake a windows desktop (http://www.readatwork.com/) etc.). Flash has never been safe…

No, it all runs within the sandbox - it’s basically a virtual machine emulated in ABC (Actionscript byte code). We could do the same in Java pretty easily, in fact.

In fullscreen mode in Flash keyboard access is disabled, probably to prevent phising websites in this style. Looks great though :slight_smile:

“Please draw your password”

Ha, that’s hilarious - gotta remember to leave that open next time I get my hands on my brother’s Linux laptop, he’ll have a fit if he thinks that I “upgraded” his system on the sly!