开发者

How can I compile Ruby to Javascript? [closed]

开发者 https://www.devze.com 2022-12-18 00:25 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

Improve this quest开发者_运维技巧ion

I'm working on a piece of logic that I would like to express on the server as well as in the browser. Something like validating a form where there must be certain logical relationships between the elements based on what has already been entered.

So... If I can write the logic once and somehow end up with both Ruby and with Javascript, I can write the logic just once and not have to worry about making sure that two pieces of code written in different languages have the same functional behaviour.

I don't need to reproduce everything in Ruby, obviously, and one simplification might be to port a single general-purpose library like Functional Javascript to Ruby.

Does anyone have experience with RubyJS? Can anyone point me to an existing project using RubyJS? Thanks in advance...


As far as I can tell, Opal is the best Ruby to JS converter/compiler out there right now. Here you can see it in action.

It isn't perfect, but it works most of the time and unlike older projects such as RubyJS, Opal is still being actively developed.


I know about http://hotruby.yukoba.jp/ but have never used it


maybe this helps: http://opalrb.org/ haven't tried it though


I recently heard about a project named "Johnson" which embeds the Spidermonkey JavaScript interpreter inside Ruby. http://github.com/jbarnette/johnson

You could then eval some javascript inside ruby.

0

精彩评论

暂无评论...
验证码 换一张
取 消