RubyRacer Basics

55 views
Skip to first unread message

Siddhartha Bhagwan

unread,
Jun 2, 2014, 3:01:28 AM6/2/14
to therub...@googlegroups.com
Hey,

I'm trying to get to understand theRubyRacer here, not a lot of content available online. Would be great if someone could help me out with a few things here - 

What I understand so far is - 
Its a JavaScript interpreter, and is required by ExecJS. It can be replaced by theRubyRhino, NodeJs and other similar engines.

1) Client side JavaScript is executed by the browsers i.e, the browsers respective JavaScript Engine for example V8 for Chrome. So the rubyracer has nothing to do with clientSide Javascript?

2) A lot of the data available shows execution and evaluation of javascript from within the ruby controller actions. When is this scenario useful? In my humble experience of 2 years in this domain, I have only seen JavaScript used on client side for DOM Manipulation, or AJAX for dynamically fetching data. In what use cases am I likely to run into the need to mix ruby and javascript in the same context?

3) Similarly, the examples shown describe accessing Ruby code from javascript as well. When and why would I need to do something like that?


If theres something else I'm majorly misunderstanding, do point it out. I'm kinda confused here.

TIA

Siddhartha

Charles Lowell

unread,
Jun 2, 2014, 9:28:07 AM6/2/14
to Siddhartha Bhagwan, therub...@googlegroups.com
Apologies. Looks like I replied to the moderator email, but in order to retain the threading, I’ll repost my answers.

cheers,

On June 2, 2014 at 8:17:04 AM, Siddhartha Bhagwan (sidunder...@gmail.com) wrote:

Hey,

I'm trying to get to understand theRubyRacer here, not a lot of content available online. Would be great if someone could help me out with a few things here - 

What I understand so far is - 
Its a JavaScript interpreter, and is required by ExecJS. It can be replaced by theRubyRhino, NodeJs and other similar engines.


It can be replaced depending on what you’re trying to accomplish. NodeJS cannot see Ruby objects, whereas The Racer and Rhino can. If you need to call Ruby functions from your JavaScript, then you’ll need one of those.




1) Client side JavaScript is executed by the browsers i.e, the browsers respective JavaScript Engine for example V8 for Chrome. So the rubyracer has nothing to do with clientSide Javascript?


No, it has nothing to do with Client side javascript. It’s “Just JavaScript” which is the power of JavaScript

2) A lot of the data available shows execution and evaluation of javascript from within the ruby controller actions. When is this scenario useful? In my humble experience of 2 years in this domain, I have only seen JavaScript used on client side for DOM Manipulation, or AJAX for dynamically fetching data. In what use cases am I likely to run into the need to mix ruby and javascript in the same context?


Some use it to safely evaluate untrusted code, or also evaluate javascript models from the client.




3) Similarly, the examples shown describe accessing Ruby code from javascript as well. When and why would I need to do something like that?


An example from LessCSS is to use rails helpers inside your .less files




If theres something else I'm majorly misunderstanding, do point it out. I'm kinda confused here.

TIA

Siddhartha


Hope that helps.


--
You received this message because you are subscribed to the Google Groups "The Ruby Racer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to therubyracer...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages