English 中文(简体)
What s the difference between Ruby and JRuby? [closed]
原标题:
Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 7 years ago.

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?

最佳回答

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.

问题回答

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.

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.

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

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.

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

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

JRuby is a Java implementation of the Ruby programming language.





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签