HotRuby: Run Ruby on a JavaScript interpreter?
Date : 2008 03 27 Category : Tech & DevelopmentThis is from the "wow, really?" department. HotRuby is an implementation of Ruby in JavaScript!
The way it works is that a HotRuby "VM" takes the resulting output from YARV and can grok it via JSON:
PLAIN TEXT RUBY:VM::InstructionSequence.compile(cgi['src'], "src", 1, OutputCompileOption).to_a.to_json
Thus, you can embed Ruby by doing something like this:
PLAIN TEXT HTML:<script type="text/ruby"> class Pi def initialize @a = 355.0 end def calc b = 113.0 return @a / b end PI = 'PI is about' end puts Pi::PI puts Pi.new.calc </script> <body onload="prettyPrint(); new HotRuby().runFromScriptTag('/compileRuby.cgi')">
Since you can run on any JavaScript interpreter or VM, they also support Flash.
For example, check out this Box2D example written in Ruby, running in Flash:
