On 9/12/06, [email protected] [email protected]
wrote:
Is it possible to write applications in Ruby and let them run in an
internet browser, just like you could with applets or flash? Preferably
without the user having to install a special plug-in…
It depends on your goals. If you want everything in Ruby then you have
to use it on the server side and then it can generate all the content
that you want. I have used Rails as a ‘launchpad’ for a Javascript
application.
It really started as a Rails application, but I wanted to achieve two
things, the first was reducing the frequency of round trips, and to
eliminate session from the server, so that it can run from anywhere.
I have considered writing Ruby code that generates JavaScript but code
generators are not the road that I thought would be best. JavaScript
and Ruby can communicate with each other, as long as you can pass your
data around as JSON, or as URL parameters (say, for updates). RJS I
wouldn’t say is a code generator, but rather it helps to orchestrate
various common scenarios for making the normal static content much
more interactive.
If you want to take this to the conclusion that I reached, then you
would write the application in Javascript and only rarely talk with
the server at which point it is no longer a Ruby application but a
JavaScript applications.
The division fell naturally into server side processing that does data
updates, fetches and validation (to get around the same origin
limitation) and the client represents the data directly as HTML
elements, or objects attached to these elements.
But what you are trying to do, I’d say that is what JavaScript was
created for. Rails comes with the prototype and scriptaculous
JavaScript libraries, which help to make your JavaScript idioms a bit
more Ruby like …
See http://semaflickr.sohne.net if you want to see what I mean …
– G.