53

Can anyone please provide me in layman's terms the difference between developing a JRuby and a Ruby, Rails application?

I use NetBeans as my Ruby on Rails IDE and every-time I create a project is asks me that question - and I don't really get the difference. Are there any pro and cons?

John Topley
  • 113,588
  • 46
  • 195
  • 237
Ash
  • 24,276
  • 34
  • 107
  • 152

8 Answers8

64

Ruby runs within a native C based interpreter. JRuby runs inside the Java Virtual Machine. There are many gems and plugins that might not work inside JRuby, specifically one's with native C extensions, unless they've been rewritten to run in Java.

Ultimately the difference comes in when you want to actually deploy your application (assuming the gems you want to use weren't an issue). If you would like to deploy to a java web server, then JRuby would be the way to go. If you have a *nix environment, then Passenger + Nginx or Apache is very popular as well, which uses the standard ruby or ruby enterprise interpreter. There is always the mongrel or thin cluster option as well, again using the standard interpreter.

danivovich
  • 4,197
  • 4
  • 30
  • 31
27

JRuby runs on the Java VM (the interpreter was written in Java), while the original Ruby interpreter was written in C. Both have up- and downsides also (Ruby can use native extensions, JRuby can access to Java types, objects etc.)

JRuby uses Ruby 1.8.6's syntax, 1.9.x will be available soon. JRuby has Java threads (meaning it will scale to many cpus, cores etc.), Ruby has some issues with userspace threading, locking ec.

Personally, I use JRuby with Glassfish v3 and Netbeans for RoR development, it scales a lot better than ruby + loads of mongrels, Apaches and it's easier to manage.

Tamas Mezei
  • 899
  • 6
  • 9
4

JRuby is the Java implementation of Ruby. It's compatible with Ruby 1.8, and lags current Ruby (1.9). It runs on a JVM and allows you to easily integrate existing Java libraries.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
4

JRuby is mostly Ruby compatible. One aspect of JRuby is that you can run it in non-compatible modes for performance reasons.

Thomas Jung
  • 32,428
  • 9
  • 84
  • 114
3

Ruby is a programming language. JRuby is an implementation of the Ruby programming language.

Asking about the difference between the two doesn't really make sense: they are on two entirely different levels of abstraction.

It's similar to asking what is the difference between a car and a Prius. It doesn't make sense, either: a Prius an implementation of the general concept of a car. You could ask what's the difference between a Prius and a Hummer or the difference between a car and an aeroplane, but the difference between a car and a Prius doesn't make sense.

Similarly, with Ruby, you could ask about the difference between Ruby and Python or JRuby and MRI, but the difference between Ruby and JRuby doesn't make sense.

Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653
  • 1
    I was meaning more on the lines of, why would use use native Ruby over JRuby (or visa versa) and why - but I voted this answer up because it does clear up some if the distinction for me. Cheers. – Ash Nov 13 '09 at 23:14
  • Well, JRuby *is* native. Native to the JVM. And for example on Windows, JRuby is actually *more* compatible with Ruby than MRI. And it has true parallel threads, unlike "native" MRI or YARV. – Jörg W Mittag Nov 14 '09 at 00:34
  • 70
    I understand the intention of this answer, but it doesn't really respond the question. Clearly Ash was trying to ask the difference between MRI and JRuby and you could've clarified without so much nitpicking and also answer the question. – Edgar Gonzalez Jun 01 '12 at 04:51
  • 6
    Its nice that youve gone to lengths to discredit someone's question. And its great to see you have not contributed anything to the community in the process :D. I see no mention of MRI in your answer. – Steve Robinson Sep 11 '13 at 06:22
  • 7
    how about not acting like a computer error message, and getting to correct and answer the intent or lack of knowledge of the user, if you have a deep understanding of the invalidity of the question? "Great, my question is invalid, and people stop talking from that point, even if they understand the intent of my question. I guess from now on, instead of expecting an answer, I'll have to tiptoe on ice before even seeking to further my knowledge or tackle my ignorance." – ahnbizcad Jun 09 '14 at 13:19
  • @gwho: Abstraction is *the* fundamental concept of programming. I expect any professional programmer to understand the difference between an abstraction and an implementation, a programming language and a compiler. This is a site for professional programmers, after all. – Jörg W Mittag Jun 09 '14 at 19:37
  • 22 votes. just saying. – ahnbizcad Jun 10 '14 at 01:05
  • 1
    @gwho: And a "Thank You" comment by the author of the question. Helping people is more important to me than reputation, if the author of the question says I helped him, that's good enough for me. – Jörg W Mittag Jun 10 '14 at 09:13
2

JRuby is a java implementation of Ruby interpreter. Rails (aka Ruby on Rails) is a web application framework written in Ruby. This article explains how Ruby code is actually executed through JVM http://patshaughnessy.net/2012/2/7/journey-to-the-center-of-jruby

RushabhM
  • 31
  • 2
0

JRuby is a Java implementation of the Ruby programming language.

0

As far as I know jruby is simply a ruby implementation written in java so it allows easy integration with the java runtime.

ennuikiller
  • 46,381
  • 14
  • 112
  • 137