Ruby in the browser
This is an area where a lot of people have done a lot of work over the years and one where we will probably end up having binary modules for our browsers to run whatever scripting language we want in the end.
Sadly that's still a long ways off and here is what you can do for now:
What you really want(but can only use for embedded applications)
But since this requires you to download another browser it's only really viable when you deliver your product as a desktop app ...
There are also some work on building a native code extension for Chrome of the Ruby runtime. I have not seen it available in any other form than code, so I haven't tried it. It's a bit better than Decaf if it get's into the app store, it means you can use it for backend type apps without much problem.
What we got so far(and it's pretty awesome!)
Currently we have the full (almost) port of Ruby 1.8.7 that Replit did (replit/emscripted-ruby). But that is 5 years old at the time of writing (early 2017) and never mind 1.9.x we have 2.4 now and 2.5 coming so it is seriously dated.
Enter the work that Matz(tm) is doing with mRuby and the similar convertion of that through LLVM/Clang called Webruby (xxuejie/webruby).
That project is, relatively, updated and compatible with a large part of the Ruby ISO standard. So it is your best bet unless you want to set up Emscripetn/LLVM on your own.
You can look at that code under the
You'll the Opal test code in the
Well, it depends...
Webruby is larger (but not by a huge factor) and slower (it's a full VM on top of another VM) but supports ISO Ruby better.
Boolean instead of
FalseClass and throws around a bit of
undefined at times.
The proof is in the eating
To see what we can do I have make a couple of pages where you can see the same Ruby code being excercised by the different engines. I try to keep the examples as close to each other as possible but library diffrences makes that impossible in some cases.
To look at and see Webruby in action have a look under the /webruby path.
And to look at and see Opal in action have a look under the /opal path.
After ever after
I'll add more tests and play around a bit more with real website programming and we'll see what wins out in the end...
Do you know of any other way of running Ruby in the browser without any binary dependencies? Fork and add code for it as well or just open an issue and I'll add it as soon as possible.
Many thanks for your time and I hope you enjoy the simple demos I have put together to show what you can do with Ruby in the browser!