From Wikipedia, the free encyclopedia
JRuby is a Java implementation of the
Ruby programming language,
being developed by the JRuby team. It is free software released under a three-way
CPL/GPL/LGPL license. JRuby
is tightly integrated with Java to allow the embedding
of the interpreter into any Java application with full two-way
access between the Java and the Ruby code (similar to Jython for the Python
JRuby's lead developers are Charles Nutter, Thomas Enebo, Ola
Bini and Nick Sieger. In September 2006, Sun
Microsystems hired Enebo and Nutter to work on JRuby full
time. In June
hired Ola Bini to work on Ruby and JRuby. In July
2009, the JRuby developers left Sun to continue JRuby development
at Engine Yard.
JRuby was originally created by Jan Arne Petersen, in 2001. At
that time and for several years following, the code was a direct
port of the Ruby 1.6 C code. With the release of
Ruby 1.8.6, an effort began to update JRuby to 1.8.6 features and
semantics. Since 2001, several contributors have assisted the
project, leading to the current (2008) core team of four
The Netbeans Ruby Pack,
available since NetBeans 6.0, allows IDE development with Ruby and JRuby, as well as
Ruby on Rails
for the two implementations of Ruby.
JRuby 1.1 added Just-in-time compilation and
compilation modes to JRuby and was already faster in most cases
than the current Ruby 1.8.7 reference implementation.
JRuby 1.1.1 is stated to be packaged in Fedora 9.
Since version 1.1.1, the JRuby team began to issue point releases
often to quickly address issues that are brought up by users.
On July 2009, the core JRuby developers, Charles Nutter, Thomas
Enebo and Nick Sieger, joined Engine Yard to continue JRuby
JRuby initially supported Ruby MRI 1.8.6, and gradually improved its
Ruby 1.9 support.
Since 1.4.0 it also support Ruby 1.8.7.
JRuby supports Ruby on Rails since version 0.9 (May
2006) , with
the ability to execute RubyGems and WEBrick. Since the hiring of the two lead
developers by Sun, Rails compatibility and speed have improved
greatly. JRuby version 1.0 successfully passed nearly all of Rails'
own test cases.
Since then, developers have begun to use JRuby for Rails
applications in production environments .
On February 27, 2008, Sun Microsystems and the University
of Tokyo announced a joint-research project to implement a
virtual machine capable of executing more than one Ruby or JRuby application
on one interpreter.
on Java Virtual Machines
JSR 292 (Supporting
Dynamically Typed Languages on the JavaTM Platform) 
- add a new
invokedynamic instruction at the JVM
level, to allow method invocation relying on dynamic type checking,
- to be able to change the classes and methods at runtime
dynamically in a production environment.
Open source project Multi Language Virtual Machine aim to
prototype this JSR. The
first working prototype, developed as a patch on OpenJDK, was announced and made available on
end of August 2008.
The JRuby team has successfully wired dynamic invocation in
their codebase, albeit in a very primitive way. Dynamic invocation
shipped with the 1.1.5 release, although being disabled on JVMs
without Dynamic invocation capabilities.
This table present only releases that present significant steps
in JRuby history, aside from versions that mainly fixed bugs and
||Performs better than Ruby MRI 1.8.7
AOT mode and JIT mode
||Refactored Java integration layer
Beginning of Ruby 1.9 support
FFI subsystem for calling C libraries
||Ruby 1.9 support almost complete (including JIT compiler)
Preliminary Android support
||JRuby runs in restricted environments better like GAE/J
||Windows Native Launcher and Windows installer
Ruby 1.8.7 support
Improved Ruby 1.9 support
Since early 2006, the current JRuby core team has endeavored to
move JRuby beyond being a simple C port, to support better
performance and to aid eventual compilation to Java bytecode. To
support this end, the team set an ambitious goal: to be able to run
Ruby on Rails
unmodified using JRuby. In the process of achieving this goal, the
JRuby test suite expanded to such extent that the team gained
confidence in the "correctness" of JRuby. As a result, toward the
end of 2006 and in the beginning of 2007, they began to commit much
more complicated redesigns and refactorings of JRuby's core
JRuby is designed to work as a mixed-mode virtual machine for
Ruby, where code can be either interpreted directly, just-in-time compiled at
runtime to Java bytecode, or ahead-of-time compiled to Java bytecode
before execution. Until October 2007, only the interpreted mode supported all
Ruby's constructs, but a full AOT/JIT compiler is available
since version 1.1.
The compiler design allows for interpreted and compiled code to run
side-by-side, as well as decompilation to
reoptimize and outputting generated bytecode as Java class files.
JRuby has built-in support for Rails, RSpec, Rake, and RubyGems. It embeds an FFI subsystem to allow to
use C libraries bundled as gems.
It also allows to launch the Interactive Ruby Shell (irb) as
Ruby MRI does.
JRuby is essentially the Ruby interpreter, except this version
is written entirely in Java. JRuby features some
of the same concepts, including object-oriented
programming, and duck-typing as Ruby. The key difference is
that JRuby is tightly integrated with Java, and can be called
directly from Java programs.
Java from JRuby
One powerful feature of JRuby is its ability to invoke the
classes of the Java Platform. To do this, one must first
load JRuby's Java support, by calling "include Java" ("require
'java'" in earlier versions). The following example creates a Java
frame = javax.swing.JFrame.new()
JRuby also allows the user to call Java code using the more
Ruby-like underscore method naming and to refer to JavaBean properties as
frame.visible = true
JRuby from Java
JRuby can just as easily be called from Java, using either the
Scripting for Java 6 or the Apache Bean Scripting
framework. More information on this is available in the JRuby Wiki article.
JRuby supports interpreted mode, AOT mode, and JIT mode (the last two modes
are available since version 1.1).
JRuby evolved from being several times slower than Ruby Reference
being several times faster.
Benchmarks as of 16 December 2009, show JRuby using between 2 and
56 times the memory of Ruby MRI.
In this mode, JRuby 1.0 was slower than the C Ruby reference. For
example, serving up Rails requests in the standard interpreted mode, JRuby was 50% to
70% slower than C Ruby
1.8. Since then, JRuby performance in interpreted mode has
improved a lot. The JRuby team claims that JRuby 1.1.4 is 15%-20%
faster in interpreted mode than Ruby MRI .
When using Ruby 1.9 (YARV)
benchmarks on Java 6, interpreted
JRuby 1.0 was 4 times slower than Ruby (including startup
JIT mode is available since
JRuby 1.1. In performance benchmarks, JRuby is consistently 200% to
300% faster than C Ruby
but still 15%-25% slower than C Ruby 1.9. However, the JRuby 1.1.6
version outperforms C Ruby 1.9 in some cases  .
Also in a real Mongrel web server application, JRuby performance is
better than Ruby (after the Virtual Machine has
Jacki (2006-09-07). "Sun Welcomes JRuby
Developers". On the Record. http://blogs.sun.com/ontherecord/entry/sun_welcomes_jruby_developers. Retrieved
Ola Bini. "ThoughtWorks". On the
- ^ a
"Sun's JRuby team jumps ship
to Engine Yard". 2009-07-27. http://www.itworld.com/business/72663/suns-jruby-team-jumps-ship-engine-yard. Retrieved
"Ruby & JRuby Support
Available in NetBeans IDE". netbeans.org. 2007-03-06. http://www.netbeans.org/servlets/NewsItemView?newsItemID=1015. Retrieved
"Ruby brightens the NetBeans
platform". infoworld.com. 2007-03-01.
- ^ a
Cangiano, Antonio (2007-03-12). "The Great Ruby
Shootout". http://antoniocangiano.com/2007/12/03/the-great-ruby-shootout/. Retrieved
Nutter, Charles (2008-04-25). "JRuby 1.1.1 in RedHat
Fedora". http://headius.blogspot.com/2008/04/jruby-111-in-redhat-fedora.html. Retrieved
fedoraproject.org. https://admin.fedoraproject.org/pkgdb/packages/name/jruby. Retrieved
"JRuby 1.1.3 Released".
jruby.codehaus.org. 2008-07-19. http://docs.codehaus.org/display/JRUBY/2008/07/19/JRuby+1.1.3+Released. Retrieved 2008-07-19.
"Our goal is to put out point releases more frequently for the
next several months (about 3–4 weeks a release). We want a more
rapid release cycle to better address issues brought up by users of
Nutter, Charles (2009-07-28). "JRuby’s Future at Engine
Yard". http://www.engineyard.com/blog/2009/jrubys-future-at-engine-yard/. Retrieved
"Ruby Future Roundup: Ruby
1.9.0-5 Released, JRuby Skips 1.8.7". infoq.com.
2008-10-08. http://www.infoq.com/news/2008/10/ruby-future-roundup-1.9.0-5. Retrieved 2008-12-06.
"Most 1.8.7 features that came from 1.9.1 are to make
transition from 1.8 to 1.9 series easier(...)users should switch
directly to 1.9 rather then writing code that only works in
- ^ a
"Rails Support". JRuby
Team. http://wiki.jruby.org/wiki/Rails_Support. Retrieved
Nutter, Charles (2008-08-24). "Zero to Production in 15
Minutes". http://blog.headius.com/2008/08/zero-to-production-in-15-minutes.html. Retrieved
98.6% of the 2,807 Rails-specific test cases execute successfully;
see JRuby 0.9.8 Released
"Success Stories". JRuby
Wiki. 2008-01-29. http://wiki.jruby.org/wiki/Success_Stories. Retrieved
"The University of Tokyo and
Sun Microsystems Commence Joint Research Projects on High
Performance Computing and Web-based Programming Languages". Sun
Microsystems. 2008-02-27. http://www.sun.com/aboutsun/pr/2008-02/sunflash.20080227.5.xml. Retrieved
see JSR 292
Investigations". Sun Microsystems. 2007. http://openjdk.java.net/projects/mlvm/subprojects.html. Retrieved
Rose, John (2008-08-26). "Happy International
Invokedynamic Day!". http://blogs.sun.com/jrose/entry/international_invokedynamic_day. Retrieved
Lorimer, R.J. (2008-09-01). "Dynamic Invocation Runs on
OpenJDK". infoq.com. http://www.infoq.com/news/2008/09/invokedynamic_day. Retrieved
Nutter, Charles (2008-09-11). "A First Taste of
InvokeDynamic". http://blog.headius.com/2008/09/first-taste-of-invokedynamic.html. Retrieved 2008-09-13. "I
managed to successfully wire InvokeDynamic directly into JRuby's
dispatch process! Such excitement! The code is already in JRuby's
trunk, and will ship with JRuby 1.1.5 (though it obviously will be
disabled on JVMs without InvokeDynamic)."
- ^ a
Nutter, Charles (2007-09-27). "The Compiler Is
Complete". http://headius.blogspot.com/2007/09/compiler-is-complete.html. Retrieved
Enebo, Tom (2008-08-28). "JRuby 1.1.4
Released". http://www.bloglines.com/blog/ThomasEEnebo/2008_8. Retrieved
Enebo, Tom (2009-03-16). "JRuby 1.2.0 Released".
JRuby Team. http://docs.codehaus.org/display/JRUBY/2009/03/16/JRuby+1.2.0+Released. Retrieved
Enebo, Tom (2009-06-03). "JRuby 1.3.0 Released".
JRuby Team. http://docs.codehaus.org/display/JRUBY/2009/06/03/JRuby+1.3.0+Released. Retrieved
"JRuby 1.4.0 Released".
JRuby Team. 2009-11-02. http://www.jruby.org/2009/11/02/jruby-1-4-0. Retrieved
"JRuby 1.4.0 Released".
adtmag.com. 2009-11-10. http://adtmag.com/articles/2009/11/10/jruby-1.4-released.aspx. Retrieved
Fox, Joshua (2006-07-17). "Script your Java
applications and efficiently reuse your Java libraries with this
dynamic language". JavaWorld. http://www.javaworld.com/javaworld/jw-07-2006/jw-0717-ruby.html. Retrieved
JSR 223: Scripting for the
Java Platform Specification Request
Cangiano, Antonio (2007-02-19). "Ruby Implementations
Shootout: Ruby vs Yarv vs JRuby vs Gardens Point Ruby .NET vs
Rubinius vs Cardinal". http://antoniocangiano.com/2007/02/19/ruby-implementations-shootout-ruby-vs-yarv-vs-jruby-vs-gardens-point-ruby-net-vs-rubinius-vs-cardinal/. Retrieved
- ^ a
Cangiano, Antonio (2008-12-09). "The Great Ruby Shootout
(December 2008)". http://antoniocangiano.com/2008/12/09/the-great-ruby-shootout-december-2008/. Retrieved
- ^ a
"JRuby compared to Ruby 1.8,
Computer Language Benchmarks Game". http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=jruby&lang2=ruby&box=1. Retrieved
Nutter, Charles (2007-04-16). "Paving the Road to JRuby
1.0: Performance". http://headius.blogspot.com/2007/04/paving-road-to-jruby-10-performance.html. Retrieved
Nutter, Charles (2008-04-27). "Promise and Peril for
Alternative Ruby Impls". http://blog.headius.com/2008/04/promise-and-peril-for-alternative-ruby.html. Retrieved 2008-12-06.
"We now run faster than Ruby 1.8 in both interpreted and
compiled modes, with interpreted being perhaps 15-20% faster and
compiled being at least a few times faster, generally on par with
Nutter, Charles (2008-11-23). "Noise Cancelling". http://blog.headius.com/2008/11/noise-cancelling.html. Retrieved 2008-12-07. "A
year ago, we were generally a bit slower than Ruby 1.8.6; this
year, we're faster in most cases than Ruby 1.9."
Nutter, Charles (2008-02-16). "JRuby RC2 Released; What's
Next?". http://headius.blogspot.com/2008/02/jruby-rc2-released-whats-next.html. Retrieved 2008-02-17.
"JRuby's performance regularly exceeds Ruby 1.8.6, and in many
cases has started to exceed Ruby 1.9."
"JRuby compared to Ruby 1.9,
Computer Language Benchmarks Game". http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=jruby&lang2=yarv&box=1. Retrieved
Sieger, Nick (2007-10-25). "JRuby on Rails: Fast
Enough". http://blog.nicksieger.com/articles/2007/10/25/jruby-on-rails-fast-enough. Retrieved
Justin; Liu, Henry (November 18, 2008), JRuby Cookbook
(First ed.), O'Reilly Media, pp. 222, ISBN 059651980X, http://oreilly.com/catalog/9780596519803/
- Bini, Ola
(September 24, 2007), Practical JRuby on Rails
Web 2.0 Projects: Bringing Ruby on Rails to Java (First
ed.), Apress, pp. 330, ISBN 1590598814, http://apress.com/book/view/9781590598818
Chris; Leonard, Brian (May 4, 2009), NetBeans Ruby and Rails
IDE with JRuby (First ed.), Apress, pp. 160, ISBN 1430216360, http://www.apress.com/book/view/1430216360