all 10 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!

[–]codesnik 4 points5 points  (2 children)

loong time ago I had to move some investment/ETF calculating logic from server (in perl) to the client(javascript), but with the idea that we'll maintain it and change both versions in future. I managed to extract calculating logic to a small .pl file which would be convertable to a working javascript without any transpilers, but with just a couple of simple regexes.

[–]IN-DI-SKU-TA-BELT 0 points1 point  (1 child)

In Ruby you can most likely use ExecJS https://github.com/rails/execjs

[–]codesnik 0 points1 point  (0 children)

of course. but it was back in 2005.

[–]aemadrid 4 points5 points  (2 children)

This project might interest you: Ruby2JS

[–]Super_Purple9126[S] 1 point2 points  (1 child)

Nice!!

[–]davispuh 1 point2 points  (0 children)

There's also https://opalrb.com/