Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
JRuby
Implementation of the Ruby programming language running on the Java Virtual Machine –

JRuby is an implementation of the Ruby programming language atop the Java Virtual Machine, written largely in Java. It is free software released under a three-way EPL/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 language).

JRuby's lead developers are Charles Oliver Nutter and Thomas Enebo, with many current and past contributors including Ola Bini and Nick Sieger. In September 2006, Sun Microsystems hired Enebo and Nutter to work on JRuby full-time. In June 2007, ThoughtWorks hired Ola Bini to work on Ruby and JRuby.

In July 2009, the JRuby developers left Sun to continue JRuby development at Engine Yard. In May 2012, Nutter and Enebo left Engine Yard to work on JRuby at Red Hat.

We don't have any images related to JRuby yet.
We don't have any YouTube videos related to JRuby yet.
We don't have any PDF documents related to JRuby yet.
We don't have any Books related to JRuby yet.
We don't have any archived web articles related to JRuby yet.

History

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 (2012[update]) core team of around six members.

JRuby 1.1 added Just-in-time compilation and Ahead-of-time compilation modes to JRuby and was already faster in most cases than the then-current Ruby 1.8.7 reference implementation.5

JRuby packages are available for most platforms; Fedora 9 was among the first to include it as a standard package at JRuby 1.1.1.67

In July 2009, the core JRuby developers at Sun Microsystems, Charles Oliver Nutter, Thomas Enebo and Nick Sieger, joined Engine Yard to continue JRuby development.89 In May 2012, Nutter and Enebo left Engine Yard to work on JRuby at Red Hat.10

JRuby has supported compatibility with Ruby MRI versions 1.6 through 1.9.3. JRuby 1.0 supported Ruby 1.8.6, with JRuby 1.4.0 updating that compatibility to Ruby 1.8.7. JRuby 1.6.0 added simultaneous support for Ruby 1.9.2, with JRuby 1.7.0 making Ruby 1.9.3 the default execution mode (Ruby 1.8.7 compatibility is available via a command-line flag). JRuby 9.0.0.0 added support for Ruby 2.2.

The current version of JRuby (9.4.3.0) targets Ruby 3.1, though some 3.1 features are still in work.11

Ruby on Rails

JRuby has been able to run the Ruby on Rails web framework since version 0.9 (May 2006),1213 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's own test cases.14 Since then, developers have begun to use JRuby for Rails applications in production environments.15

Multiple virtual machine collaboration

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.16

Dynamic invocation on Java Virtual Machines

JSR 292 (Supporting Dynamically Typed Languages on the JavaTM Platform)17 proposes:

  • adding a new invokedynamic instruction at the JVM level, allowing method invocation using dynamic type checking,
  • dynamically changing classes and methods at runtime.

The Sun Open source project Multi Language Virtual Machine aims to prototype this JSR.18 The first working prototype, developed as a patch on OpenJDK, was announced and made available on end of August 2008.1920

The JRuby team has implemented dynamic invocation into their codebase. Dynamic invocation initially shipped with the 1.1.5 release in a primitive form.21 Version 1.7.0 enabled it by default on Java 8 builds.22

Release history

This table presents only releases that present significant steps in JRuby history, aside from versions that mainly fixed bugs and improved performance. Performance improvements are also not shown in the table below, as every release has usually brought such improvements.

ReleaseRelease DateHighlights
0.9August 1, 2006Rails support23
1.1March 28, 2008Performs better than Ruby MRI 1.8.724AOT mode and JIT mode25
1.1.4August 28, 2008Refactored Java integration layerBeginning of Ruby 1.9 supportFFI subsystem for calling C libraries26
1.2.027March 16, 2009JIT compiler for Ruby 1.9Preliminary Android support by the Ruboto project.
1.3.028June 3, 2009JRuby runs in restricted environments better like GAE/J
1.4.02930November 2, 2009Windows Native Launcher and Windows installerRuby 1.8.7 support
1.5.031May 12, 2010Native Launcher for UNIX-based platformsAnt support and Rake-Ant integrationUpdates to the standard library, RubyGems, and RSpec
1.6.032March 15, 2011Ruby 1.9.2 language and API compatibilityBuilt-in profilerExperimental support for C extensions based on Ruby’s C API
1.7.033October 22, 2012Ruby 1.9.3 language is the default modeSupport for invokedynamic
1.7.434May 16, 2013Experimental Ruby 2.0 support (most features and stdlib included)
9.0.0.035July 22, 2015Ruby 2.x supportNew optimizing runtimeNew POSIX-friendly IO and Process

Fully ported encoding/transcoding logic from MRI

9.1.7.036January 11, 2017Fixed serious LinkageError when using multiple threads

Fixed several keyword argument issues

Fixed several parser issues

Reduced memory use of the JIT

Update Psych to 2.2.2

Update jruby-openssl to 0.9.18

72 issues fixed

9.2.0.037May 24, 2018Ruby 2.5 language support
9.2.9.038October 30, 2019Ruby 2.5.7 language support
9.3.2.039December 2, 2021Ruby 2.6.x language support
9.3.3.040January 19, 2022Ruby 2.6.x language support
9.3.4.041March 23, 2022Ruby 2.6.x language support
9.4.0.042November 22, 2022Ruby 3.1 language support
9.4.1.043February 7, 2023Ruby 3.1 language support
9.4.2.044March 8, 2023Ruby 3.1 language support
9.4.3.045June 7, 2023Ruby 3.1 language support

Design

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 subsystems.

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.46 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.

Frameworks support

JRuby has built-in support for Rails, RSpec, Rake, and RubyGems. It embeds an FFI subsystem to allow the use of C libraries bundled as gems. It also allows launching the Interactive Ruby Shell (irb) as Ruby MRI does.

The Netbeans Ruby Pack, available in NetBeans 6, allows IDE development with Ruby and JRuby, as well as Ruby on Rails for the two implementations of Ruby.4748 It is no longer included in NetBeans 7.0 and later.

Programming

Ruby meets Java

JRuby is similar to the standard Ruby interpreter except written in Java. JRuby features some of the same concepts, including object-oriented programming, and dynamic typing as Ruby. The key difference is that JRuby is tightly integrated with Java, and can be called directly from Java programs.49 Java has significant footing in the development of web applications.

JRuby calling Java

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 "require 'java'". The following example creates a Java JFrame with a JLabel:

require 'java' frame = javax.swing.JFrame.new frame.getContentPane.add javax.swing.JLabel.new('Hello, World!') frame.setDefaultCloseOperation javax.swing.JFrame::EXIT_ON_CLOSE frame.pack frame.set_visible true

JRuby also allows the user to call Java code using the more Ruby-like underscore method naming and to refer to JavaBean properties as attributes:[dubious – discuss]

frame.content_pane.add label frame.visible = true

Calling JRuby from Java

JRuby can just as easily be called from Java, using either the JSR 22350 Scripting for Java 6 or the Apache Bean Scripting framework.

//Example using JSR 233 Scripting for Java 6 ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine rbEngine = mgr.getEngineByExtension("rb"); try { rbEngine.eval("puts 'Hello World!'"); } catch (ScriptException ex) { ex.printStackTrace(); }

Performance

According to some benchmarks, JRuby is faster than alternatives. Since implementations vary in how much code is loaded before execution, different methods of measuring speed can lead to biased interpretations of performance advantages. The time it takes for a Java Virtual Machine itself to load is often excluded from execution times when calculating benchmarks.

JRuby has the significant architectural advantage to be able to leverage JVM threads without being constrained by a global interpreter lock (similarly to Rubinius), therefore achieving full parallelism within a process, which Ruby MRI cannot achieve despite leveraging OS threads.

In a real Mongrel web server application tested in 2007, JRuby performance is better than Ruby MRI 1.8, after the Java Virtual Machine had been instantiated.51

In a 2007 benchmark of Ruby implementations, JRuby was faster than Ruby MRI 1.8 in some tests, but YARV outperformed both of them.52

As of April 2014, in The Computer Language Benchmarks Game, JRuby 1.7.4 typically has the same performance as Ruby MRI 2.1.0, but uses more memory.5354

See also

  • Free and open-source software portal
  • Computer programming portal

Further reading

References

  1. Jacki (September 7, 2006). "Sun Welcomes JRuby Developers". On the Record. Archived from the original on August 29, 2012. Retrieved November 7, 2013. https://web.archive.org/web/20120829225411/https://blogs.oracle.com/ontherecord/entry/sun_welcomes_jruby_developers

  2. Ola Bini (2007). "ThoughtWorks". On the Record. http://ola-bini.blogspot.com/2007/03/thoughtworks.html

  3. "Sun's JRuby Team Jumps Ship to Engine Yard". PCWorld. July 28, 2009. Archived from the original on July 31, 2009. Retrieved June 2, 2012. https://web.archive.org/web/20090731094537/http://www.pcworld.com/article/169145/suns_jruby_team_jumps_ship_to_engine_yard.html

  4. "Red Hat lures in JRuby power pair". The Register. May 23, 2012. Retrieved June 2, 2012. https://www.theregister.co.uk/2012/05/23/red_hat_hires_j_ruby_brains/

  5. Cangiano, Antonio (March 12, 2007). "The Great Ruby Shootout". Retrieved February 1, 2008. http://antoniocangiano.com/2007/12/03/the-great-ruby-shootout/

  6. Nutter, Charles (April 25, 2008). "JRuby 1.1.1 in RedHat Fedora". Retrieved April 26, 2008. http://headius.blogspot.com/2008/04/jruby-111-in-redhat-fedora.html

  7. "jruby". fedoraproject.org. Retrieved April 26, 2008.[permanent dead link] https://admin.fedoraproject.org/pkgdb/packages/name/jruby

  8. "Sun's JRuby Team Jumps Ship to Engine Yard". PCWorld. July 28, 2009. Archived from the original on July 31, 2009. Retrieved June 2, 2012. https://web.archive.org/web/20090731094537/http://www.pcworld.com/article/169145/suns_jruby_team_jumps_ship_to_engine_yard.html

  9. Nutter, Charles (July 28, 2009). "JRuby's Future at Engine Yard". Archived from the original on July 31, 2009. Retrieved July 28, 2009. https://web.archive.org/web/20090731123454/http://www.engineyard.com/blog/2009/jrubys-future-at-engine-yard/

  10. "Red Hat lures in JRuby power pair". The Register. May 23, 2012. Retrieved June 2, 2012. https://www.theregister.co.uk/2012/05/23/red_hat_hires_j_ruby_brains/

  11. "Unfinished Ruby 3.1 features". JRuby Team. Retrieved June 13, 2023. https://github.com/jruby/jruby/issues/7460

  12. "Rails Support". JRuby Team. Archived from the original on March 3, 2008. Retrieved February 17, 2008. https://web.archive.org/web/20080303021232/http://wiki.jruby.org/wiki/Rails_Support

  13. Nutter, Charles (August 24, 2008). "Zero to Production in 15 Minutes". Retrieved August 27, 2008. http://blog.headius.com/2008/08/zero-to-production-in-15-minutes.html

  14. 98.6% of the 2,807 Rails-specific test cases execute successfully; see JRuby 0.9.8 Released Archived May 22, 2015, at the Wayback Machine http://docs.codehaus.org/display/JRUBY/2007/03/05/JRuby+0.9.8+Released

  15. "Success Stories". JRuby Wiki on GitHub. January 5, 2011. Retrieved March 16, 2011. https://github.com/jruby/jruby/wiki/SuccessStories

  16. "The University of Tokyo and Sun Microsystems Commence Joint Research Projects on High Performance Computing and Web-based Programming Languages". Sun Microsystems. February 27, 2008. Retrieved February 28, 2008. http://www.sun.com/aboutsun/pr/2008-02/sunflash.20080227.5.xml

  17. see JSR 292 http://www.jcp.org/en/jsr/detail?id=292

  18. "Sub-Projects and Investigations". Sun Microsystems. 2007. Retrieved February 6, 2008. http://openjdk.java.net/projects/mlvm/subprojects.html

  19. Rose, John (August 26, 2008). "Happy International Invokedynamic Day!". Retrieved September 3, 2008. https://blogs.oracle.com/jrose/entry/international_invokedynamic_day

  20. Lorimer, R.J. (September 1, 2008). "Dynamic Invocation Runs on OpenJDK". infoq.com. Retrieved September 3, 2008. http://www.infoq.com/news/2008/09/invokedynamic_day

  21. Nutter, Charles (September 11, 2008). "A First Taste of InvokeDynamic". Retrieved September 13, 2008. 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). http://blog.headius.com/2008/09/first-taste-of-invokedynamic.html

  22. "JRuby 1.7.0 Released". JRuby Team. October 22, 2012. Archived from the original on October 25, 2012. Retrieved October 23, 2011. https://web.archive.org/web/20121025001231/http://www.jruby.org/2012/10/22/jruby-1-7-0.html

  23. "Rails Support". JRuby Team. Archived from the original on March 3, 2008. Retrieved February 17, 2008. https://web.archive.org/web/20080303021232/http://wiki.jruby.org/wiki/Rails_Support

  24. Cangiano, Antonio (March 12, 2007). "The Great Ruby Shootout". Retrieved February 1, 2008. http://antoniocangiano.com/2007/12/03/the-great-ruby-shootout/

  25. Nutter, Charles (September 27, 2007). "The Compiler Is Complete". Retrieved October 12, 2007. http://headius.blogspot.com/2007/09/compiler-is-complete.html

  26. Enebo, Tom (August 28, 2008). "JRuby 1.1.4 Released". Retrieved February 25, 2009.[permanent dead link] http://www.bloglines.com/blog/ThomasEEnebo/2008_8

  27. Enebo, Tom (March 16, 2009). "JRuby 1.2.0 Released". JRuby Team. Archived from the original on March 19, 2009. Retrieved March 17, 2009. https://web.archive.org/web/20090319000144/http://docs.codehaus.org/display/JRUBY/2009/03/16/JRuby+1.2.0+Released

  28. Enebo, Tom (June 3, 2009). "JRuby 1.3.0 Released". JRuby Team. Archived from the original on June 12, 2009. Retrieved June 3, 2009. https://web.archive.org/web/20090612104551/http://docs.codehaus.org/display/JRUBY/2009/06/03/JRuby+1.3.0+Released

  29. "JRuby 1.4.0 Released". JRuby Team. November 2, 2009. Retrieved November 3, 2009. http://www.jruby.org/2009/11/02/jruby-1-4-0

  30. "JRuby 1.4.0 Released". adtmag.com. November 10, 2009. Archived from the original on November 15, 2009. Retrieved November 21, 2009. https://web.archive.org/web/20091115202727/http://adtmag.com/articles/2009/11/10/jruby-1.4-released.aspx

  31. "JRuby 1.5.0 Released". JRuby Team. May 12, 2010. Archived from the original on May 16, 2010. Retrieved May 12, 2010. https://web.archive.org/web/20100516225724/http://jruby.org/2010/05/12/jruby-1-5-0

  32. "JRuby 1.6.0 Released". JRuby Team. March 15, 2011. Retrieved March 15, 2011. http://www.jruby.org/2011/03/15/jruby-1-6-0.html

  33. "JRuby 1.7.0 Released". JRuby Team. October 22, 2012. Archived from the original on October 25, 2012. Retrieved October 23, 2011. https://web.archive.org/web/20121025001231/http://www.jruby.org/2012/10/22/jruby-1-7-0.html

  34. "JRuby 1.7.4 Released". JRuby Team. May 16, 2013. Retrieved May 19, 2013. http://www.jruby.org/2013/05/16/jruby-1-7-4.html

  35. "JRuby 9.0.0.0 Released". JRuby Team. July 22, 2015. Archived from the original on July 24, 2015. Retrieved July 25, 2015. https://web.archive.org/web/20150724183209/http://jruby.org/2015/07/22/jruby-9-0-0-0.html

  36. "JRuby 9.1.7.0 Released — JRuby.org". jruby.org. Archived from the original on January 16, 2017. Retrieved January 13, 2017. https://web.archive.org/web/20170116160817/http://jruby.org/2017/01/11/jruby-9-1-7-0.html

  37. "JRuby 9.2.0.0 Released". Archived from the original on May 27, 2018. Retrieved May 27, 2018. https://web.archive.org/web/20180527202544/http://jruby.org/2018/05/24/jruby-9-2-0-0.html

  38. "JRuby 9.2.9.0 Released". Retrieved November 5, 2019. https://www.jruby.org/2019/10/30/jruby-9-2-9-0.html

  39. "JRuby 9.3.2.0 Released". Retrieved January 11, 2022. https://www.jruby.org/2021/12/02/jruby-9-3-2-0.html

  40. "JRuby 9.3.3.0 Released". Retrieved January 19, 2022. https://www.jruby.org/2022/01/19/jruby-9-3-3-0.html

  41. "JRuby 9.3.4.0 Released". Retrieved March 23, 2022. https://www.jruby.org/2022/03/23/jruby-9-3-4-0.html

  42. "JRuby 9.4.0.0 Released". Retrieved December 1, 2022. https://www.jruby.org/2022/11/23/jruby-9-4-0-0.html

  43. "JRuby 9.4.1.0 Released". Retrieved February 15, 2023. https://www.jruby.org/2023/02/07/jruby-9-4-1-0.html

  44. "JRuby 9.4.2.0 Released". Retrieved June 13, 2023. https://www.jruby.org/2023/03/08/jruby-9-4-2-0.html

  45. "JRuby 9.4.3.0 Released". Retrieved June 13, 2023. https://www.jruby.org/2023/06/07/jruby-9-4-3-0.html

  46. Nutter, Charles (September 27, 2007). "The Compiler Is Complete". Retrieved October 12, 2007. http://headius.blogspot.com/2007/09/compiler-is-complete.html

  47. "Ruby & JRuby Support Available in NetBeans IDE". netbeans.org. March 6, 2007. Archived from the original on July 19, 2011. Retrieved July 4, 2009. https://web.archive.org/web/20110719115409/http://netbeans.org/servlets/NewsItemView?newsItemID=1015

  48. "Ruby brightens the NetBeans platform". infoworld.com. March 1, 2007. Retrieved July 4, 2008. http://www.infoworld.com/d/developer-world/ruby-brightens-netbeans-platform-390

  49. Fox, Joshua (July 17, 2006). "Ruby for the Java world". JavaWorld. Retrieved July 26, 2020. https://www.infoworld.com/article/2071794/ruby-for-the-java-world.html

  50. JSR 223: Scripting for the Java Platform Specification Request http://jcp.org/aboutJava/communityprocess/final/jsr223/index.html

  51. Sieger, Nick (October 25, 2007). "JRuby on Rails: Fast Enough". Retrieved October 28, 2007. http://blog.nicksieger.com/articles/2007/10/25/jruby-on-rails-fast-enough

  52. Cangiano, Antonio (December 3, 2007). "The Great Ruby Shootout". Retrieved February 2, 2014. http://programmingzen.com/2007/12/03/the-great-ruby-shootout/

  53. "JRuby compared to Ruby 1.9, Computer Language Benchmarks Game (1)". Archived from the original on January 23, 2015. Retrieved February 2, 2014. https://web.archive.org/web/20150123023501/http://benchmarksgame.alioth.debian.org/u64q/jruby.html

  54. "JRuby compared to Ruby 1.9, Computer Language Benchmarks Game (2)". Archived from the original on July 23, 2014. Retrieved February 2, 2014. https://web.archive.org/web/20140723042024/http://benchmarksgame.alioth.debian.org/u64/jruby.php