4.0.0

Latest release in branch 4.0
Released 18 days ago (December 25, 2025)

Software Ruby
Branch 4.0
End of bug fixes
End of life
First official release version 4.0.0
First official release date 18 days ago (December 25, 2025)
Release notes https://ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/
Documentation https://ruby-doc.org
Download https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.0.tar.gz
Ruby 4.0 Releases View full list

What is New in Ruby 4.0

Ruby 4.0 brings a range of thoughtful updates that improve performance, refine the language syntax, and enhance developer experience while maintaining backward compatibility in most areas. This release focuses on making the runtime faster, Ractors more practical, and error messages clearer, alongside promoting several useful libraries into the core.

Key Language and Core Improvements

The language sees several small but helpful changes. Logical operators like ||, &&, and, and or can now continue from the previous line when placed at the start of a new line, similar to method chaining with dots.

A new top-level module called Ruby is introduced to hold Ruby-related constants. An experimental feature, Ruby::Box, can be enabled with the environment variable RUBY_BOX=1 to isolate monkey patches, global variables, and loaded libraries.

Performance Enhancements

Performance gets a significant boost across the board. A new experimental JIT compiler named ZJIT is introduced, built with Rust, and activated via --zjit. While still early, it shows promise for future speed gains.

YJIT receives further optimizations, including new runtime stats and configuration options like mem_size: and call_threshold:.

Ractor parallelism improves through reduced global lock contention, lock-free data structures for frozen strings and symbols, per-ractor object allocation counters, and faster method and instance variable access. Garbage collection becomes more efficient with independent heap growth per object size pool, faster sweeping, and deferred internal tables.

Common operations like Class#new, object_id, and hash on classes and modules are noticeably quicker.

Ractor Changes

Ractors gain better synchronization tools with the new Ractor::Port class, which supports sending, receiving, and closing. Methods like Ractor#join, Ractor#value, and Ractor.select make working with ractors feel more like threads. Older methods such as Ractor.yield and Ractor#take are removed in favor of these cleaner alternatives.

Core Class Updates

  • Array adds #rfind and an optimized #find.
  • Binding provides new ways to handle implicit numbered parameters and the "it" parameter.
  • Enumerator.produce accepts a size keyword for better control.
  • ErrorHighlight now shows code snippets from both caller and callee in ArgumentError messages.
  • Fiber gains #raise(cause:) and scheduler hooks for interrupts and IO operations.
  • Math adds log1p and expm1.
  • Pathname and Set are promoted to core classes, with Set getting a simpler #inspect format.
  • String updates to Unicode 17.0 and Emoji 17.0, and strip methods accept selector arguments.
  • Socket supports open_timeout for connections.

Standard Library Promotions and Updates

Several libraries move from default gems to bundled core, including ostruct, pstore, benchmark, logger, rdoc, and irb. Many others receive version bumps with bug fixes and improvements.

Error Handling and Debugging

Argument errors now include clearer backtraces with receiver class information and code snippets from both sides of the call. Internal frames are hidden from backtraces for cleaner output.

Compatibility Notes

Some older features are removed, such as piped process creation via Kernel#open or IO methods, and certain Process::Status operators. The CGI library is largely removed, leaving only escape utilities.

Overall, Ruby 4.0 delivers a more efficient and modern runtime while keeping the language familiar and productive.

Releases In Branch 4.0

Version Release date
4.0.0 18 days ago
(December 25, 2025)
4.0.0-preview3 25 days ago
(December 18, 2025)
4.0.0-preview2 1 month ago
(November 17, 2025)