Jruby on Rails VS. Ruby on Rails, What's Difference

JRuby on Rails vs. Ruby on Rails, what's difference?

JRuby is the Ruby implementation that runs on a JVM whereas Matz's Ruby is a C implementation.

Key features to note are:

  1. JRuby runs on Java VM's and it's either compiled or interpreted down to Java byte code.
  2. JRuby can integrate with Java code. If you have Java class libraries (.jar's), you can reference and use them from within Ruby code with JRuby. In the other direction you can also call JRuby code from within Java. JRuby can also use the JVM and application server capabilities.
  3. JRuby is usually hosted within Java application servers such as Sun's GlassFish or even the Tomcat web server.
  4. Although you cannot use native Ruby gems with JRuby there are JRuby implementations for most of the popular Ruby libraries.

There are other differences which are listed at the JRuby wiki:

  • Differences between JRuby and Ruby (MRI)
  • JRuby On Rails

JRuby on Rails vs. Ruby on Rails, what's difference?

The original answer still stands and isn't really time specific. JRuby is just a version of Ruby that runs on the Java Virtual Machine (JVM). If you're starting from scratch, just go for plain Ruby. JRuby is mostly useful to people who have existing Java code and would like their JRuby and Java apps to communicate.

What's the difference between Ruby and JRuby?

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.

How do Rails and Jruby relate?

First, I should mention that Ruby on Rails is simply Ruby code, and the same code can run in the JRuby environment (on the JVM) or the MRI (written in C) runtime.

However, only JRuby can load Java classes and use a Java API. Asking your clients to switch their deployment environment to JRuby may not be feasible, but if you can set up a service in Java that speaks XML or JSON then they will be able to easily use it from Rails.

Is JRuby a viable alternative to the MRI for Rails development?

Realistically you don't need code completion for Rails. TextMate is by far the most commonly used editor in the Ruby world, and it's more than sufficient for everything in Ruby. Ruby doesn't require anywhere near as much tool support as Java. So I would say that if the editor issue is the only reason you're opting for JRuby, it's not a very good reason. Because you're right, there are lots of gems that don't work in JRuby because they use a native extension of some kind. That said, the most popular gems tend to work in JRuby. Performance in JRuby still isn't quite as good as Ruby 1.9, but in a lot of cases it's comparable to MRI 1.8. Personally, I'd recommend treating JRuby as an advanced Ruby concept. It will run Rails, but yes, you're going to find that you won't be able to just follow along with a tutorial, and everything will be ever-so-slightly harder for a beginner. JRuby isn't a particular daunting piece of technology, but it might be more of a hurdle than you want to overcome as a beginner.

I highly recommend shelling out the Euros for a copy of TextMate anyways, even if you don't do your development in it primarily. It's worth every penny and then some. Work in that environment for awhile and see if you really need your IDE. I'm betting you won't.



Related Topics



Leave a reply



Submit