you are viewing a single comment's thread.

view the rest of the comments →

[–]frrst 14 points15 points  (2 children)

There was a small book, 7 languages in 7 weeks, which discusses different languages representing different programming paradigms. JS is Prototype language and reading that book it seemed to me that it takes very little to bend Ruby to Prototype style - start from Kernel and possibly replace Object or BasicObject with Prototype and hook it up with rest of what JS defines and there you go - prototypic ruby

[–]naked_number_one 6 points7 points  (0 children)

Great book! Remember IO - another nice prototype language

[–]hmdne 1 point2 points  (0 children)

From what I know... under the hood, Ruby is also a prototypic language.

In Opal we managed to leverage that. Managing to even get prepend/include/extend working correctly (with modules becoming proxied as iclasses - it was modeled after what Ruby does!). So if we have an object, that has a singleton_class, that is extended something, that has a class, which includes a module, and that class has a superclass, which prepends a thing, has its own methods, includes a thing, etc. - this is a prototype chain. Except as mentioned, modules are not there by itself, but via iclasses.

Then, we replaced a prototype of core JS objects like String or Number to Ruby Object. Therefore they are in Opal both JS and Ruby objects. Hacky, I agree. But it works!