Feeds

Adobe adopts Alchemy for Microsoft .NET mindshare

Feel the burn

The Power of One Brief: Top reasons to choose HP BladeSystem

Adobe MAX Europe Adobe Systems has provided more details on a research project that converts and compiles C and C++ to ActionScript and brings raw speed to the Flash virtual machine.

Alchemy enables re-use of existing C libraries within the Flash runtime. Examples shown here at MAX Europe include OpenSSL encryption code, code to generate image files in PNG format, and code to preview PDF documents in Flash. Part of the rationale is that there is more open-source code in C or C++ than in any other language.

It turns out that code re-use is not the only reason to take an interest in Alchemy. The other reason is performance, since Alchemy code generally runs substantially faster than manually written ActionScript, up to around 30 per cent of the speed of native code.

This means you might also use Alchemy to optimize Flash applications, and Adobe Flash Player engineer Jim Corbett said he expects this kind of usage to be common. But why is Alchemy code faster? And why has Adobe not optimized the ActionScript runtime to run normal code equally well?

The answer is Alchemy code runs in a different way. ActionScript 3.0 is a modern garbage-collected language similar in many respects to Java or C#. This imposes a performance overhead, and Scott Petersen, who developed Alchemy, found his early experiments impossibly slow as a result.

Adobe solved this by adding a special per-application byte array in the Flash 10 player. This becomes the memory available to Alchemy code. "All the code does is jump around a byte array," according to chief scientist Mark Anders. The consequence is that the code runs up to 25 times faster, but the developer has to manage memory just as with native C programming.

That said, errors like buffer overruns or memory leaks, while they may crash the Alchemy application, should not have wider consequences. "All the security stuff works exactly as it does in ActionScript today," said Corbett.

There are other reasons why Alchemy code runs faster. The project uses the Low-Level Virtual Machine (LLVM) compiler, an open source project that compiles C and C++ to optimized intermediate code. Alchemy then compiles this intermediate code to ActionScript, which is not human-readable. "The LLVM tools optimize a lot better than the ActionScript tools," Corbett said.

Alchemy opens up a number of intriguing possibilities. One is support for other dynamic languages within Flash, using existing open source interpreter code.

"We've been working on Ruby and Lua and even Java," Corbett told MAX. It is also ideal for number-crunching algorithms and will be eyed with interest by game developers.

It glitters, but it 'ain't gold

Unfortunately, there are some snags. One is that all applications that use Alchemy include the compiled version of the C standard library, which adds around 140K to the download size. It is possible that Adobe will create a signed version of this library, enabling it to be installed in a local cache where it would be shared. However, apparently all Alchemy code is poorly optimized for size as yet.

Another problem is that while Alchemy code itself is fast, marshalling objects across the boundary between normal ActionScript and Alchemy code is slow and difficult to code, though there is a wrapper library called GlueGen that simplifies this to some extent. It is not suitable for applications that make a lot of these transitions. Debugging is currently primitive. Adobe will not say when Alchemy will be ready for production use or even if it will ever make it out of the Adobe Labs research area - though given the high level of interest that seems likely.

This is also a project that may help Adobe in its battle with Microsoft for developer mindshare. Silverlight's .NET runtime executes non-visual code faster than ActionScript in some tests, but probably not as fast as Alchemy, and if Adobe delivers the ability to execute other dynamic languages via an Alchemy interpreter, that could be an answer to Microsoft's Dynamic Language Runtime for .NET. ®

Securing Web Applications Made Simple and Scalable

More from The Register

next story
Apple fanbois SCREAM as update BRICKS their Macbook Airs
Ragegasm spills over as firmware upgrade kills machines
HIDDEN packet sniffer spy tech in MILLIONS of iPhones, iPads – expert
Don't panic though – Apple's backdoor is not wide open to all, guru tells us
NO MORE ALL CAPS and other pleasures of Visual Studio 14
Unpicking a packed preview that breaks down ASP.NET
Captain Kirk sets phaser to SLAUGHTER after trying new Facebook app
William Shatner less-than-impressed by Zuck's celebrity-only app
Do YOU work at Microsoft? Um. Are you SURE about that?
Nokia and marketing types first to get the bullet, says report
Microsoft takes on Chromebook with low-cost Windows laptops
Redmond's chief salesman: We're taking 'hard' decisions
Cheer up, Nokia fans. It can start making mobes again in 18 months
The real winner of the Nokia sale is *drumroll* ... Nokia
EU dons gloves, pokes Google's deals with Android mobe makers
El Reg cops a squint at investigatory letters
prev story

Whitepapers

Designing a Defense for Mobile Applications
Learn about the various considerations for defending mobile applications - from the application architecture itself to the myriad testing technologies.
How modern custom applications can spur business growth
Learn how to create, deploy and manage custom applications without consuming or expanding the need for scarce, expensive IT resources.
Reducing security risks from open source software
Follow a few strategies and your organization can gain the full benefits of open source and the cloud without compromising the security of your applications.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.
Consolidation: the foundation for IT and business transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.