One language, many Rubies
"Ruby" is first of all a language – the rules for what 3.times { puts "bacon" } means. The program that runs such code is a Ruby implementation, and there is more than one. The one almost everybody means is CRuby, also called MRI ("Matz's Ruby Interpreter"): written in C, developed by Matz and the Ruby core team, and the reference for all the others – a new Ruby version is a new CRuby. It runs this course too: ruby.wasm is CRuby compiled to WebAssembly. Three constants tell you where your code is running:
puts RUBY_ENGINE # which implementation
puts RUBY_VERSION # which version of the language
puts RUBY_PLATFORM # which kind of machine
RUBY_DESCRIPTIONruby is CRuby's name for itself. wasm32-wasi means: not Windows, not Linux, not a Mac – a WebAssembly machine with WASI, a standard way for WebAssembly programs to reach files and the clock. On your computer it would say something like x86_64-linux or arm64-darwin24.
On a computer, CRuby also brings JIT compilers, which turn Ruby code that runs often into machine code while the program runs: YJIT (since Ruby 3.1, from Shopify, written in Rust) and, new in Ruby 4.0, ZJIT, its experimental successor. In the browser there is neither – WebAssembly cannot create new machine code while it runs:
if defined?(RubyVM::YJIT)
"YJIT is here, enabled: #{RubyVM::YJIT.enabled?}"
else
"no YJIT in this Ruby"
endJRuby and TruffleRuby: Ruby on Java's VM
JRuby (since 2001, led for many years by Charles Nutter and Thomas Enebo) runs Ruby on the Java Virtual Machine. That brings the JVM's JIT and garbage collectors, threads that really run in parallel – CRuby lets only one thread at a time run Ruby code (the GVL, the global VM lock) – and every Java library: after require "java", java.util.ArrayList.new is an object like any other. JRuby 10.1 is compatible with Ruby 4.0; its RUBY_ENGINE is "jruby".
TruffleRuby started in 2013 as a research project at Oracle Labs. It is built with GraalVM's Truffle framework: an interpreter written in Java, which the Graal compiler turns into very fast machine code – in many benchmarks the fastest Ruby there is. It runs C extensions too, and can mix in other GraalVM languages such as Python or JavaScript. TruffleRuby 40 is compatible with Ruby 4.0; RUBY_ENGINE is "truffleruby".
Small Rubies: mruby, mruby/c and PicoRuby
mruby is Matz's second Ruby (since 2012): a lightweight one to build into other programs, the way many games carry the scripting language Lua. A C program links mruby and runs Ruby code inside – compiled beforehand to compact bytecode, if you like (mrbc). Its core follows the ISO standard for Ruby (ISO/IEC 30170, 2012); everything else, even regular expressions or Time, comes as an mrbgem chosen when mruby is built. It powers the DragonRuby Game Toolkit, among others, and its build configurations reach from the Nintendo Switch to the Game Boy Advance – and to WebAssembly: mruby 4.0 comes with configurations for Emscripten and WASI, so mruby runs in a browser, too.
mruby/c (from the Shimane IT Open-Innovation Center and the Kyushu Institute of Technology) is a VM even smaller than mruby's own, for microcontrollers with a few dozen kilobytes of memory; it runs mruby's bytecode. And PicoRuby (by HASUMI Hitoshi) is a whole Ruby for one-chip microcontrollers such as the Raspberry Pi Pico: compiler and VM on the chip, a shell called R2P2, an IRB, libraries for LEDs, sensors and Wi-Fi. Since version 4 it runs on mruby's VM.
PicoRuby runs as WebAssembly as well – PicoRuby.wasm – and it is in this page already: the index, the lesson text and the editors you see are drawn by Ruby code on PicoRuby.wasm (0.9 MB), which is up a fraction of a second after the page is requested, while CRuby (10 MB) is still loading in the background. The next lesson runs your code on it.
IronRuby, RubyMotion and DragonRuby
IronRuby brought Ruby to Microsoft's .NET: started at Microsoft in 2007, 1.0 in 2010 – and left behind soon after, at Ruby 1.9 (its last release, 1.1.3, is from 2011). Now it is back: Largo/ironruby, a fork by the author of this course, runs on .NET 8 and 10 and reads Ruby with Prism – CRuby's own parser – so it speaks Ruby 4.0: IronRuby 4.0 is Ruby 4.0, with pattern matching, it and endless methods, IRB, RubyGems and Bundler – and require "System.Windows.Forms" builds Windows programs in Ruby.
RubyMotion compiles Ruby ahead of time into native apps for iPhone, iPad, the Mac and Android. Laurent Sansonetti built it after leading MacRuby at Apple and released it in 2012 with his company HipByte; one of the best-known apps made with it is the game A Dark Room by Amir Rajan. Today RubyMotion belongs to DragonRuby, whose DragonRuby Game Toolkit (by Amir Rajan and Ryan C. Gordon) is built on mruby: an engine for 2D games in Ruby that exports the same game to Windows, macOS, Linux, the browser and phones.
And many more
- Opal compiles Ruby to JavaScript: no Ruby VM in the browser – the Ruby becomes JavaScript.
- Natalie compiles Ruby to C++, and from there to a program; still work in progress.
- monoruby is a Ruby with a JIT compiler of its own, written in Rust.
- Artichoke (a Ruby in Rust) was archived in 2025, and Rubinius (Ruby largely written in Ruby), MacRuby (Ruby for the Mac, RubyMotion's ancestor), MagLev and Topaz are history.
What keeps them all compatible are shared tests: ruby/spec, started by the Rubinius team, describes how Ruby behaves in thousands of examples, and every implementation runs it. Code that wants to work everywhere asks RUBY_ENGINE where a difference matters:
def threads_in_parallel?
# JRuby and TruffleRuby run threads truly in parallel,
# CRuby lets one thread at a time run Ruby (the GVL)
%w[jruby truffleruby].include?(RUBY_ENGINE)
end
threads_in_parallel?The usual Ruby version managers install the other Rubies, too: rbenv install --list (from ruby-build) shows jruby-…, truffleruby-… and mruby-… next to the CRuby versions, and ruby-install and mise know them as well. JRuby 10 needs a Java runtime, version 21 or newer.
which_ruby(engine): it gets a RUBY_ENGINE and returns the implementation's usual name – "ruby" → "CRuby", "jruby" → "JRuby", "truffleruby" → "TruffleRuby", "mruby" → "mruby" – and any other name as it is.def which_ruby(engine)
# "ruby" -> "CRuby", "jruby" -> "JRuby", ...
end
which_ruby(RUBY_ENGINE)