Thursday, September 04, 2008

Ruby and V8

Summer is drawing to a close and many of the things which have distracted me from my blog are becoming less pressing, so it's about time for me to crank this back up — we'll have to see how well I keep up with it. Of course, there are a lot of exciting things on the horizon that are prompting me to write. One of the biggest is the release of V8, the JavaScript VM that's part of Google's Chrome. Over on the Strongtalk list, David Griswold wrote:
I still think it or some derivative will quickly become the dominant dynamic language VM, for the following reasons:
  • Given who the developers are, and with Google behind it, it will be the fastest JavaScript VM for a long time to come.
  • For the same reason, it will be reliable and secure (as much as it can be, anyway; nothing is perfect).
  • It will be supported on the three major platforms (Windows, Linux, Mac).
  • It can be used with other browsers, so I'm sure it will be ported to Firefox (if only as an option). Some or all of the other browsers may also adopt it, given that it will have a very hard-to-overcome performance advantage (these sorts of VMs can't be pulled out of a hat). Although MS and maybe Safari may have too much of a Not Invented Here problem with it, as well as standards war issues.
  • those things, plus the other architectural advantages it brings, will make it a primary target for serious web app development, esp. Google apps.
  • So it will be ubiquitous
So it will be an irresistible platform for other dynamic languages, even if they could theoretically run a bit faster on a custom VM. Remember it will still be a lot easier to run other dynamic languages on JavaScript than it is to run them on Java, since at least JavaScript is fully dynamic, unlike Java.
I'm not the language guru that David is, but I not ready agree with him yet. While JRuby is showing good progress at creating a fast, stable Ruby implementation on top of a non-native VM, I don't think we've seen what a native, tuned VM for Ruby can really do. I'm also not sure we'll ever see Ruby's community turn away from their own VM (be it Rubinius or the 1.9 VM) for the 'standard implementation'. This doesn't mean that V8 is without value to the Ruby community though. Again, David Griswold:
The V8 development team has multiple members of the original Animorphic team; it is headed by Lars Bak, who was the technical lead for both Strongtalk and the HotSpot Java VM (as well as a huge contributor to the original Self VM). I think that you will find that V8 has a lot of the creamy goodness of the Strongtalk and Self VMs, with many big architectural improvements:
  • open source
  • will run (eventually) on Windows, Linux, and Mac
  • dynamically JITs to native code
  • can run completely independently from the browser
  • generates hidden classes behind the scenes, since javascript doesn't have them (very reminiscent of the 'maps' used in the Self VM).
  • is multi-threaded from the ground up, with the ability to share VM overhead between different OS processes.
  • has even smaller object headers than in Strongtalk, making small object overhead even smaller
  • kick-ass compacting, non-conservative garbage collector
Whether Ruby ends up on V8 or not, I'm guessing that some of V8 will end up in Ruby.

4 comments:

Charles Oliver Nutter said...

Wouldn't implementing Ruby on top of a VM designed for JavaScript be just as non-native as implementing Ruby on top of a VM designed for Java? And if Ruby code compiles down to JVM bytecode, which gets further compiled down to native code, what would make it "more native"?

blowmage said...

I think V8 is an exciting development for sure. While the current incarnation may not be the perfect fit for Ruby, I expect that to change (or evolve) over time. Pretty exciting regardless.

gnupate said...

Charles,
I think you're reading a slam where none was attended. I think JRuby is an example of why V8 could work well for Ruby.

I don't think the JVM or V8 will ever be seen as 'the Ruby' because neither of came from the Ruby community. Hopefully that clears things up.

Christiaan said...

I would like V8 on my server instead of IIS Jscript. Could it connect to mssql?