Forum: JRuby Difference between Ruby and JRuby

1edf4136a746d28531367e517e8f0a67?d=identicon&s=25 Mike Disuza (mike412)
on 2011-08-05 07:54
Hi,

Can anyone tell me what is the difference between ruby and jruby?

I have read that JRuby means, java implementation of Ruby. What does
that mean? Is it mean that ruby interpretor is written in java?

Also, Is all ruby API methods are available in JRuby? like array, hash
etc.

Thanks,
Mike.
83a96a69fb6b2a1ce108d9e192a6f019?d=identicon&s=25 Jeffrey Jones (Guest)
on 2011-08-05 08:01
(Received via mailing list)
The essential difference is that JRuby compiles down to Java byte-code
and is executed on the Java Virtual Machine. MRI uses it's own
interpreter.

This of course means you need Java installed on your system.

JRuby when used in 1.8.7 mode is fully api compatible with MRI ruby.
JRuby when used in 1.9.2 is pretty close to full API compatibility I
think, not totally sure.

There may be a few gems that give you trouble on JRuby but they are few
and far between.
1edf4136a746d28531367e517e8f0a67?d=identicon&s=25 Mike Disuza (mike412)
on 2011-08-05 08:11
Thanks Jeffrey for your instant reply.
This means that I can write the ruby code as it is which will be
interpreted by JVM and everything will be same.

Jeffrey Jones wrote in post #1015074:
> The essential difference is that JRuby compiles down to Java byte-code
> and is executed on the Java Virtual Machine. MRI uses it's own
> interpreter.
>
> This of course means you need Java installed on your system.
>
> JRuby when used in 1.8.7 mode is fully api compatible with MRI ruby.
> JRuby when used in 1.9.2 is pretty close to full API compatibility I
> think, not totally sure.
>
> There may be a few gems that give you trouble on JRuby but they are few
> and far between.
83a96a69fb6b2a1ce108d9e192a6f019?d=identicon&s=25 Jeffrey Jones (Guest)
on 2011-08-05 08:17
(Received via mailing list)
In terms of what you write, there is no difference, it is all ruby. The
magic happens further down.

It is only when you start to take advantage of JRuby's unique features
(such as linking with java libraries) that your code really stops being
portable between MRI and JRuby

If you are on a *nix system the best way to give JRuby a try is to
install the Ruby Version Manager, use that to install JRuby then run
some of your scripts / applications ( Have a look at
http://jruby.org/getting-started ).
1edf4136a746d28531367e517e8f0a67?d=identicon&s=25 Mike Disuza (mike412)
on 2011-08-05 11:03
Thanks a lot Jeffrey.
5ad1d27cc11a293dd7fc32a9aceb2725?d=identicon&s=25 Sathish R. (sathish_r)
on 2013-11-29 14:38
Hi,

      I have ruby on rails app with me.Now I wanna integrate my app with
JRuby in order to get asynchronous feature.How do I approach?
      Any help would be greatly appreciated,thanks in advance
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2013-11-29 15:10
(Received via mailing list)
On Fri, Nov 29, 2013 at 5:38 AM, Sathish R. <lists@ruby-forum.com>
wrote:

>       I have ruby on rails app with me.Now I wanna integrate my app with
> JRuby in order to get asynchronous feature.How do I approach?

First, don't start by "replying" to a 2+ year old thread; start a new
topic.

Second, just run your app with JRuby. If you have specific problems,
ask about them and provide details.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
486ca04f06d968004643ce5b47376ded?d=identicon&s=25 Keith B. (keith_b)
on 2013-11-30 00:39
(Received via mailing list)
Sathish -

Welcome to this group.

I'm wondering if your expectations of JRuby are realistic.  What exactly
do
you mean by asynchronous?  Are you referring to JRuby's superior
threading?  What specifically are you trying to improve?  Have you
identified a problem?

I strongly recommend the JRuby book:
http://pragprog.com/book/jruby/using-jruby

- Keith
5ad1d27cc11a293dd7fc32a9aceb2725?d=identicon&s=25 Sathish R. (sathish_r)
on 2013-12-02 07:40
Thanks Keith for the reply.
           Let me explain my scenario.Am basically a java programmer.One
of my client had ruby on rails app(prior to 3.9 version) with him.He
approached me and asked
to convert his existing ruby on rails app to asynchronous.He himself
suggested ,do it with Play framework.
            When I raise this question with Play experts,they suggested
me to go with JRuby.Since then I have set up Jruby in my machine and
made my trails.But I could not get rid of it.
            Please suggest me ,how do I go with little detail
explanation.
            Thank you very much.



-Sathish Reddy
486ca04f06d968004643ce5b47376ded?d=identicon&s=25 Keith B. (keith_b)
on 2013-12-02 16:17
(Received via mailing list)
Sathish -

I wish you well, but to be honest, it sounds like youll need more
assistance than what can be provided here.  In addition, although you
reiterated your request for help, you didnt answer any of the questions
I raised to help us help you.  In addition, you were asked to be more
specific in your questions.

- Keith
5ad1d27cc11a293dd7fc32a9aceb2725?d=identicon&s=25 Sathish R. (sathish_r)
on 2013-12-04 13:04
Keith,
    Thanks for taking time to look at it.I agree that I did not answer
your questions,since I was not aware much about JRuby superior
threading and other kind of stuff.

-Sathish
C983ad33b47479f17a28e083e1bb3d8b?d=identicon&s=25 Eric West (edubkendo)
on 2013-12-04 21:13
(Received via mailing list)
@Sathish ,

I would strongly encourage you to do two things:

   1.

   Read Using JRuby <http://pragprog.com/book/jruby/using-jruby> . You
can
   work though it quickly and the examples and material contained in it
will
   give you some ideas about how you can use JRuby to improve the
performance
   of your clients app. You might also want to check out Deploying
JRuby<http://pragprog.com/book/jkdepj/deploying-with-jruby>as it has a
lot of useful information about some of the main deployment
   options.
    2.

   Spend some time reading through articles on the JRuby
wiki<https://github.com/jruby/jruby/wiki>as they should provide a way
to deepen the knowledge gleaned from the book,
   without requiring you to spend too much time on any of them.

This should give you a better idea about JRuby, and the how and why it
is
typically used by other developers. This video, Why JRuby
Works<http://confreaks.com/videos/1281-rubyconf2012-why-...
some of this reasoning as well, and might be an even better
starter point.

It might be the case that you could switch the rails app to JRuby, have
it
run with very few changes, and get an immediate performance boost simply
due to JRubys better performance. The material I recommended will
assuredly instruct you in how to do this.

As for going asynchronous, it might be possible to use the Play
framework,
via JRuby, to build an asynchronous application. I dont know of anyone
who
has done that, personally, although it has probably been tried. You
cannot
just take a rails app, suddenly slap in JRuby and Play and have it be
asynchronous however. Rails and Play are each frameworks in their own
right, and Im not even sure where one would begin to hook them together.

Usually, when people talk about asynchronous code in conjunction with
Rails, they mean running selected parts of the Rails stack in an
asynchronous way. Typically I/O heavy parts. Most often, they mean
running
it with an asynchronous server.

The two libraries most typically used to do async programming in Ruby
are
EventMachine <http://rubyeventmachine.com/> and
Celluloid<http://celluloid.io/>,
specifically Celluloid I/O <https://github.com/celluloid/celluloid-io>.
Of
those two, Id most highly recommend Celluloid, for many reasons, but
especially because it doesnt just give you Celluloid I/O for writing
asynchronous code, but instead Celluloid provides an entire concurrency
toolkit built around the Actor model. (Play framework is also built on
top
of the Actor model abstraction, but I believe Play hides this all from
you
instead of making it available to the end user).

Probably your easiest option for adding some async sauce to a Rails app
would be to swap out the server for one written with one of those two
libraries I mentioned above. Id suggest
Reel<https://github.com/celluloid/reel-rack>.
That said, you might get better improvements just switching to JRuby
*for
the native threading capability* and then using something like
Puma<http://puma.io/>which is specifically intended for use in Rack
applications like those
built with Rails, or one of the other deployment options recommended in
the
book I mentioned. TorqueBox <http://torquebox.org/> would be another
great
choice.

It will depend on your clients use case, and you should definitely try
several things and do some benchmarking.
Abdb670e1c130f96f947a94d03c02efa?d=identicon&s=25 Eric Christopherson (echristopherson)
on 2013-12-05 03:53
(Received via mailing list)
On Mon, Dec 2, 2013 at 12:40 AM, Sathish R. <lists@ruby-forum.com>
wrote:

> explanation.
>             Thanks you very much.
>

It sounds to me like your client wanted his existing code ported to Play
(presumably using Java or Scala).
5ad1d27cc11a293dd7fc32a9aceb2725?d=identicon&s=25 Sathish R. (sathish_r)
on 2013-12-05 11:10
-Eric West

           Thank you so much for elaborated explanation.I will follow
the steps suggested by you,hope would find the solution.


-Sathish
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.