HotRuby: A JavaScript & Flash Virtual Machine That Runs Ruby
HotRuby is a JavaScript and Flash powered virtual machine that can run Ruby code compiled to opcode by YARV.
You can write Ruby script within a Web page within <script type="text/ruby"> .. </script> tags, and HotRuby will then extract it, send it to be compiled by a remote script, and then return it for the JavaScript and Flash powered virtual machine to display within the page. There are lots of demos, including a physics Flash application (as seen in the screenshot above), a very curious pinball game, and a benchmarking script (which shows HotRuby as being 78% faster than Ruby 1.9 on my machine?)
There's also a live "do it yourself" coding environment if you want to give it a test by writing some code of your own.
March 26, 2008 at 12:18 pm
wow.
!!!
I've gotta say that blew me away. Pretty remarkable stuff, even for an initial prototype. Incredibly, on my computer, this implementation of a YARV VM in javascript (using firefox 2 btw, which isn't the fastest) was faster than my ruby 1.8 and 1.9.
March 26, 2008 at 7:18 pm
Change the "+=" into "<<" and Ruby is again 100 times faster :)
For a comparison of RubyJS vs. HotRuby take a look here:
http://www.ntecs.de/blog/articles/2008/03/26/rubyjs-vs-hotruby
Nevertheless, great stuff!
March 26, 2008 at 8:06 pm
I'm afraid I've wrecked the physics demo. The chain came of the the little tractor thingy and I can't get it back on!
This cannot be a page of code to write. That's insane! And brilliant.
Another page of code for the tractor repair shop.
March 26, 2008 at 8:23 pm
Awesomeness.
But, I can't get the pinball game to stop "freezing."
Well, it's better than having my entire browser freeze though...
March 26, 2008 at 10:11 pm
That's amazing. Considering the gains we can get with small additions to it, I can see how a lot of people could contribute to fill the gaps.
March 27, 2008 at 1:34 am
Very nice idea!
On my machine it takes 6.90 seconds in the Browser using HotRuby and 6.61 seconds if I run the benchmark-code in a local script under Windows.
March 27, 2008 at 2:18 am
Something is very fishy about these speed results. I need to do some more digging, but I think this apparent speed disparity has to do with differing garbage collection/memory schemes.
The code:
50000.times{|e| sum += e.to_s}
will create a HUGE number of new string objects laying around the heap (string concatenation creates new strings.)
A simple fibonacci function yields very different results:
def fib(n)
return n if n == 0 or n == 1
fib(n-1)+fib(n-2)
end
On my Ruby 1.8.6 this took 0.019 seconds.
HotRuby took 2.911 seconds.