Wednesday, September 3, 2008


I've been playing around with the Low Level Virtual Machine toolkit a bit recently, which is a whole suite of tools for implementing compilers, virtual machines, and other goodies only a C.S. major could love. I'd always been vaguely aware of the project, but a couple of recent developments made me think it's time to take a serious look at it:


The first was the presentation that Scott Peterson of Adobe gave at the 2008 LLVM Developer's Meeting a few weeks ago (slides and video here). Scott's managed to get LLVM bytecode running on top the the Flash VM, which has all sorts of interesting implications (although it seems a bit backwards - shouldn't the high-level virtual machine i.e. Flash run on top of the low-level virtual machine - not the other way around?). In particular, it means that you could potentially run arbitrary C programs in the browser, since a C-to-LLVM bytecode compiler already exists.

Most of the major programming languages out there have interpreters written in C, so it follows that you could then run Ruby or Python or whatever in the modified Flash runtime without a whole lot of work. The browser would become even more like an OS, hosting arbitrary applications and giving them low-level APIs for accessing the DOM and other resources, instead of imposing particular languages or object models. Huzzah.

Unfortunately, it doesn't look like FlaCC will be supported anytime time, which means we'll have to limp along with Javascript and Actionscript for the time being. And to be honest I can't see a reason why Adobe would want to support this - if I could run vanilla Ruby in the browser, why would I pony up the big bucks for all those ActionScript development tools?

Snow Leopard

The second interesting development is Apple's use of LLVM in the next release of their operating system, code named Snow Leopard. It appears that both Grand Central (which distributes processing across cores) and OpenCL (which distributes processing between the CPU and the GPU) will make use of LLVM. In fact, Apple seems to be throwing so much weight behind the LLVM project, that it makes be wonder if they're building their own LLVM-based browser plugin. There does seem to be a rather gaping hole in this chart:

CompanyPreferred LanguageVirtual Machine
MicrosoftC#, Visual Basic.NET CLR
SunJavaJava Virtual Machine

Since Apple refuses to support Flash on the iPhone, and they haven't been shy about using iTunes as a way to get users to install other Apple software, my guess is that they will release an LLVM-based browser plugin at some point. Just a hunch.

Anyway, to get the hang of things I'm working on a LLVM backend for a Lisp-like language. More to come...

No comments: