Sunday, May 3, 2009

An introduction to mach1

Mach1 is a(nother) ruby implementation. Its (somewhat ambitious) long-term goal is a faster ruby. The current short-term goal is just to be able to run mspec, so I can see just how wrong it is.

There's actually a lot of interesting work in the ruby implementation space at the moment - commercial stuff like crosstwine's faster ruby 1.8 & 1.9 versions, maglev, and blueruby; and opensource stuff like jruby, rubinius, and tinyrb.

I started mach1 mid-March, based on the Extensible Object Model paper by Ian Piumarta (much referenced - by _why (potion), Marc-Andre Cournoyer (tinyrb) and Evan Phoenix (rubinius)). In fact my starting point was the sample id-objmodel code, and the dynamic dispatch is still heavily based on that approach. I'm a fan of the work the VPRI guys are doing, and previously had a crack at bringing the elegance of Ometa to ruby (see ruby-ometa).

At the moment, mach1's execution model is similar to idc (from the COLA project), consisting of AOT compilation to C, and thus to native code. It relies on a host ruby (to leave the pain of ruby parsing to ruby_parser), which converts source to bytecode. A further pass converts that to C. This is only required the first time a file is run, *and for every eval*. There is also the beginnings of a pure interpreter, but it needs updating.

Longer term, obviously other approaches are planned (JIT etc), but we'll see if things ever get that far.

Regardless of the execution strategy, the object model, dispatch, and core internal methods are all provided by the same runtime (within the runtime/ directory).

Anyway, if you want to take a look or help out, its on github. It's still pretty messy code, but at only ~5kloc, its small enough to understand fairly easily.

A first post

Well, I've finally got around to adding my voice to the masses - welcome to my Token Blog!

I (expect I) will be mostly gibbering about various open source projects I'm working on. At the moment, the one I'm spending some time on is mach1.