TL; DR: JRuby is an open-source implementation of the Ruby programming language using the Java Virtual Machine (JVM). The tool makes for a faster version of Ruby. It can also be used to run Ruby on the JVM to access powerful libraries and embed Ruby as a scripting language in Java programs. With the release of JRuby 126.96.36.199 on the horizon, the JRuby community is furthering its mission to ensure continual compatibility with Ruby while adding robust new features.
We’ve all heard the phrase “don’t reinvent the wheel,” but the advice is especially appropriate in the software development world. Writing every bit of code from scratch is not just time-consuming, but it opens the door to human error.
Looking for the best of both worlds? Try JRuby, an open-source implementation of the Ruby programming language using the Java Virtual Machine (JVM). As a replacement for Ruby’s interpreter, JRuby allows code to be executed as if it were Java. In doing so, JRuby runs faster than Ruby and allows developers to use Java libraries in their code.
“We like to say, ‘It’s just Ruby,’ meaning that even though you get the benefits from the Java platform, you don’t have to be a Java developer to use JRuby,” said Charles Oliver Nutter, Co-Lead of the JRuby project. “Yet JRuby’s performance continues to increase with every release of Java.”
The Best of Both Worlds: Uniting Ruby Syntax and the JVM
JRuby’s tight integration with Java allows the interpreter to call directly from Java programs while retaining JRuby concepts like object-oriented programming and dynamic typing.
In addition to libraries, JRuby allows developers to access the Java garbage collection feature, a memory management tool that finds and deletes unused objects to free up space. They can also use the JVM just-in-time (JIT) compiler, which compiles bytecode into native code at runtime to improve performance.
Integration with Java also allows JRuby to be embedded into Java applications.
“We focus very closely on being a first-class JVM citizen and an excellent JVM language, fitting into the standard Java environment, and allowing developers to use all of the libraries,” Charles said. “At the same time, we also try to be as Ruby-centric as possible.”
Interest in the JRuby project has spiked since its 2001 inception, partially due to increased popularity in the Ruby on Rails web development framework. JRuby has been able to run the Ruby on Rails web framework since the May 2006 release of version 0.9. The interpreter also supports RSpec, Rake, and RubyGems.
The project’s most recent release, JRuby 188.8.131.52, introduced minor fixes.
“The JRuby 9.2 series is compatible with Ruby 2.5,” Charles said. “We have JRuby 9.3 ready to go with 2.6 support. It was intended for a launch last spring but was delayed due to COVID. Once we get JRuby 9.3 out — hopefully in the next month — the next version of JRuby will go straight to Ruby 3.0 compatibility.”
Broad Platform Support and User-Fueled Updates
Having the Ruby programming language sit atop the JVM empowers programmers to build, package, and distribute applications to end users on various platforms.
“We have a huge array of platform support — of course including all the standard ones, including Linux, windows, Berkeley Software Distribution (BSD), macOS,” Charles said. “But we’ve got users that are running on obscure platforms, MIPS processors. We’ve got people on IBM mainframes and old HP machines. Anywhere JVM can run, we can be there.”
Charles told us that he doesn’t expect the JRuby community to take the same app and deploy it on 20 different hardware platforms. It’s about providing developers the ability to choose the best option for them.
“If you want to deploy on x86, if you want to deploy on an ARM, ARM64, or AArch64 hardware platform, if you want to apply on some larger, older system that happens to be sitting around, you can do that,” he said. “And even if you’re deploying on one of the typical platforms, we don’t require any C compilers. We don’t have any native-level libraries that can get in the way of compatibility across, say, Linux distributions. You just package up a JRuby app, and as long as there’s a JVM, you’re ready to go.”
Today, several cloud and hosting services support JRuby, which developers can deploy on any Java-compliant application server. Popular options include Tomcat, JBoss, and GlassFish.
Involvement from the JRuby Community
Charles told us that, in addition to keeping up with Ruby updates, user feedback plays a considerable role in the internal development process.
“A lot of the input comes in from end users who are trying to pull in a new Java library or integrate with a new feature of one of the newer JVMs,” Charles said. “We actually have a major contributor right now who is reworking how we extend classes in Java.”
Moving forward, the JRuby community will also remain focused on ensuring compatibility with Ruby. The goal is to always remain just a step behind.
“As far as the big things coming down the line, we’re going to make the jump to Ruby 3.0 compatibility,” Charles said. “We’ll definitely have that as a release before the end of the year — we will be less than a year behind standard Ruby once again.”
There will also be progress on the Java side.
“The current long-term supported release of OpenJDK (an open-source implementation of the Java Platform) is version 11,” Charles said. “This fall, we will get the next long-term supported major release 17, and that we will start to focus very heavily on integrating all of those interim features once that long-term support release is out.”
In the meantime, take JRuby for a spin with TryRuby.org, an interactive tutorial that runs atop a sandboxed, server-side instance of JRuby.