2 ms·
There are a number of existing projects that compile a partial Ruby into JS: * https://github.com/superchris/rubyjs https://github.com/superchris/rubyjs * htt
by jashkenas 16y ago
There are a number of existing projects that compile a partial Ruby into JS:
* https://github.com/superchris/rubyjs https://github.com/superchris/rubyjs
* https://github.com/jessesielaff/red https://github.com/jessesielaff/red
* https://github.com/tlrobinson/cappruby https://github.com/tlrobinson/cappruby
I'm afraid that Ruby semantics don't align too well with JavaScript semantics. Things as basic as numbers, method dispatch, and variable scoping don't work the same way. Either you end up with perfectly valid code written in one that doesn't run on the other, or you have an extremely slow Ruby interpreter implemented on top of JavaScript.
This is the main reason why CoffeeScript tries to stick as close to JavaScript as possible.
- stcredzero 16y agoPerfectly valid code that runs in one and not the other is fine, so long as context switching can be minimized between browser and server. (It's still a switch, but smaller.)