Feeds

Adobe adopts Alchemy for Microsoft .NET mindshare

Feel the burn

Securing Web Applications Made Simple and Scalable

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. ®

Bridging the IT gap between rising business demands and ageing tools

More from The Register

next story
NO MORE ALL CAPS and other pleasures of Visual Studio 14
Unpicking a packed preview that breaks down ASP.NET
Cheer up, Nokia fans. It can start making mobes again in 18 months
The real winner of the Nokia sale is *drumroll* ... Nokia
Mozilla fixes CRITICAL security holes in Firefox, urges v31 upgrade
Misc memory hazards 'could be exploited' - and guess what, one's a Javascript vuln
Put down that Oracle database patch: It could cost $23,000 per CPU
On-by-default INMEMORY tech a boon for developers ... as long as they can afford it
Google shows off new Chrome OS look
Athena springs full-grown from Chromium project's head
Apple: We'll unleash OS X Yosemite beta on the MASSES on 24 July
Starting today, regular fanbois will be guinea pigs, it tells Reg
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
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.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Top 8 considerations to enable and simplify mobility
In this whitepaper learn how to successfully add mobile capabilities simply and cost effectively.
Seven Steps to Software Security
Seven practical steps you can begin to take today to secure your applications and prevent the damages a successful cyber-attack can cause.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.