Decaf: Ruby in the Browser
trydecaf.org
trydecaf.org
Interesting choice, here, in going with Ruby. Ruby is not exactly intended for embedding, and I imagine that a veritable mountain of holes in the script sandbox would need to be plugged before anything like this could see mainstream adoption. On the other hand, people are likely to be a lot more excited about native Ruby support in a browser than they would be about Lua.
Overall, I wish this project much success. It will be a long road, but I hope Ruby is just the first language to be supported in this way...
It's a modified version of WebKit. WebKit devs won't allow this to be part of WebKit itself (https://lists.webkit.org/pipermail/webkit-dev/2013-April/024...).
Even if it's actively maintained (and maintaining a fork of WebKit, even if it adds just one feature, is super hard), it'll be of extremely limited appeal.
Basically it's a custom, "toy" browser that you have to download and the ruby scripts you write will not be usable by anyone else (because no one else will use that browser).
There's no way this thing gets traction.
Nevertheless: kudos to the author for a cool hack.
It's a custom, toy browser with Ruby support, not "Ruby in the Browser" (where the implication is that the browser == chrome or firefox or safari).
I'm just trying to clarify that so that people don't get the wrong impression from the misleading title.
Your children one day will laugh at you saying our parents only had javascript in the browser.
Stop thinking about market adoption.
I'm not saying it's necessarily a good idea, but I'm also not convinced it is a terrible one. I need to think about it more before I decide where I personally land, but my point is that there is absolutely a place for a tool like this.
[1] http://fluidapp.com [2] http://en.wikipedia.org/wiki/Mozilla_Prism
Is asm.js going to be a useful halfway point?
Food for thought -- can you describe to someone why using bytecode would be faster? V8 is pretty damn fast, would it really be made any faster by using a bytecoded VM instead?
There are other reasons to use a bytecode VM besides performance, but the one with the code wins, in this case :-)
But including an entire emscripten'd ruby environment on your website just because you don't want to use JS seems insanely inefficient, and no bytecode is going to fix that.
P.S. I mean shared libraries in the abstract sense, not .so or .dll files specifically.
You probably could establish a bytecode for that purpose, but the problem is that putting it at a higher level (where real interaction with the DOM is possible) gives you an impedance mismatch between object (how messages are dispatched) and execution models (how things like exceptions propagate) that can only be overcome at some degree of a performance loss.
I'm not saying that can't be solved, but I don't think anyone's put any serious effort into doing so in a generalizable way.
Sure, it was an embrace-and-extend move, but I'm not sure it was a bad idea even so.
What I'm getting at in a somewhat snarky and roundabout way is that VBScript killed multilanguage support in browsers.
There is hardly any popular language today you could embed and get better performance than JS anyway, except for Lua, which barely qualifies as 'popular'.
Meanwhile there are a hundred cross-compilers/transpilers out there that give you the kind of syntax you want, without requiring a ton of changes in browsers.
PDF: [http://research.microsoft.com/en-us/um/people/emeijer/papers...]
Language fanboys might bash javascript, but there are many examples of the great things that can be achieved with javascript that make them look really quite silly, and every language has its pitfalls. Javascript is not a bad language, but it is misunderstood and people who misunderstand it are the most vocal detractors.
Opening up the browser to many languages causes the tower of babel all over again. Now front-end devs won't just be required to be a "javascript ninja", they will now have to master many other languages in addition to all of the DOM wackiness that comes with supporting multiple browsers. It's all just too much.
I created RedScript to try and bring Ruby syntax into the browser, still pretty experimental though (and not the real thing!).
Plenty of projects are underway to get code that runs on "some of the machines very well all the time". asm.js, Google Native Client, and now that Blink has become a thing, I'll bet Dart gets it own VM in the most popular web browser in the world.
There is something to be said for ubiquity that programmers of other languages just don't get. Ruby might seem like a good idea to put into a browser but it will run slow as shit compared to the javascript engines that are in modern browsers. A lot of development has gone into optimizing javascript engines. Ruby, not so much.
Javascript is also the easiest language to learn, requires no boilerplate, and will run inside any web browser since the mid 90s, and the code you write with it can run instantly in any web browser, no installation required, just a URL to click on. There are so many reasons to learn javascript and develop with it, it is really unique and should remain that way. I'd really rather not go back to the days when there were two front-end languages, or worse, coffeescript.
On the other hand, the fact that this currently requires the user to install it first, seems to make it less portable than a compile-to-JS solution like Opal (http://opalrb.org/). At least until standard support for multiple scripting languages actually does get introduced to browser engines.
Cool project, regardless!
<script> tag has a type attribute. IE used to (still does?) support Visual Basic as a script. See http://www.w3schools.com/vbscript/vbscript_howto.asp
But even the combined might of IE and Microsoft (that was long time ago, when Microsoft and IE were mighty) couldn't get it broadly adopted so it's effectively dead.
Ideally, browsers would expose some kind of assembly-level language and you could define your own interpreter.
Those people are freaks anyway.
http://en.wikipedia.org/wiki/Steve_Gibson_%28computer_progra...
Not to mention that the whole entry screams "freak" in lots of places. I mean, how is this at all typical of the average programmer:
"Gibson is an advocate of assembly language programming, and prides himself on writing smaller applications mostly in Intel x86 assembly language"
It wouldn't be as useless as one might assume. There is Opal [1], a Ruby-to-JavaScript compiler, which could potentially be used as a fallback for web browsers that don't natively support Ruby.
[1]https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...
And all working active ports of Ruby use either the MRI lexer/parser verbatim or a mostly direct port of it. The JRuby port has the good graces to at least break the thousands of lines of lexing out into a few basic functions based on the first char of the token rather than leaving it in a giant switch statement, though.
I see the web inspector works -- it would be fantastic to be able to build apps using nothing but the web inspector, save them and serve them, rinse and repeat.
Great work.
goto the web inspector console, make sure the page_context = rb
* Ruby 2.0.0
> RUBY_VERSION "2.0.0"
Yay
* automated string conversion does not happen, you would need to do it your self
>Time.now
Time {}
>Time.now.to_s
"2013-04-08 19:47:14 -00700"
* top most object is not Kernel
>Time.ancestors
[Time, Module, Object, Kernel, BasicObject]
curious to know what standard libraries are included, hope will update the post with new findings soon
* eval works >eval("2+3") 5
* able to extend objects
* browser specific classes Window(possibly a singleton), EventTarget, Console , BarInfo
* if you open multiple windows, it acts like a seperate irb instance, though console history is available