JRuby: An Open-Source Implementation of Ruby for the JVM with Several Server Options

Jruby Is Where Ruby Meets The Jvm

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

That’s why developers love JavaScript libraries. These reusable, prewritten code snippets are well-tested and actively developed, offering an efficient way to perform JavaScript functions.

The problem is, JavaScript libraries are intended for the development of JavaScript-based applications. And not every developer wants to use JavaScript.

JRuby logo

JRuby is an implementation of the Ruby language atop of a JVM.

As a prototype-based language, JavaScript has no explicit classes, which can be difficult for software developers who are accustomed to class-based programming languages.

Rather than navigating potentially anonymous prototypes in JavaScript, many find the nominal classes in programming languages like Ruby are easier to learn. Ruby is also better for CPU-intensive application development. At the same time, Ruby has limitations in terms of scalability and runtime speed and performance.

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

A sparkling red Ruby reading

Developers don’t need to know JavaScript to work with JRuby, which is compatible with Ruby.

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 9.2.17.0, 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.

Advertiser Disclosure

HostingAdvice.com is a free online resource that offers valuable content and comparison services to users. To keep this resource 100% free, we receive compensation from many of the offers listed on the site. Along with key review factors, this compensation may impact how and where products appear across the site (including, for example, the order in which they appear). HostingAdvice.com does not include the entire universe of available offers. Editorial opinions expressed on the site are strictly our own and are not provided, endorsed, or approved by advertisers.

Our Editorial Review Policy

Our site is committed to publishing independent, accurate content guided by strict editorial guidelines. Before articles and reviews are published on our site, they undergo a thorough review process performed by a team of independent editors and subject-matter experts to ensure the content’s accuracy, timeliness, and impartiality. Our editorial team is separate and independent of our site’s advertisers, and the opinions they express on our site are their own. To read more about our team members and their editorial backgrounds, please visit our site’s About page.