TL;DR

Ruby 4.0.0 is now available, introducing an experimental isolation feature called Ruby Box, a new JIT compiler named ZJIT, and a set of Ractor concurrency improvements. The release also includes numerous language and core-class updates, plus promotions of some stdlib modules to core.

What happened

The Ruby core team released Ruby 4.0.0 with several headline changes. Ruby Box is an experimental feature (Ruby::Box) that isolates definitions, allowing separate namespaces for classes, monkey patches, globals and loaded libraries; it is activated by setting RUBY_BOX=1. ZJIT, a next-generation just-in-time compiler written with a more conventional method-compiler design, is included and can be enabled at build time with –zjit; building with ZJIT requires Rust 1.85.0 or newer. ZJIT currently outperforms the interpreter but trails YJIT in throughput, and maintainers advise experimentation rather than immediate production deployment. Ractor received new synchronization primitives (Ractor::Port), shareable Proc helpers, reductions in global-lock contention and other internal changes to improve parallelism. The release adds numerous language, core-class and stdlib tweaks — for example new Array and Enumerator methods, improved error highlighting, updates to Binding and Fiber APIs, and promotions of Pathname and Set to core.

Why it matters

  • Ruby Box offers a mechanism to run isolated code environments inside a single Ruby process, which can limit cross-test or cross-app interference.
  • ZJIT represents an architectural shift toward a larger compilation unit and SSA-based IR that aims to raise Ruby's performance ceiling and simplify external contributions.
  • Ractor improvements reduce contention and add communication primitives, advancing Ruby’s parallel-execution model toward production readiness.
  • Promoting commonly used stdlib modules to core (Pathname, Set) simplifies availability and may affect dependency and compatibility considerations.

Key facts

  • Ruby Box is experimental and enabled by setting the environment variable RUBY_BOX=1; the feature is represented by the class Ruby::Box.
  • ZJIT is a new JIT compiler; to build Ruby with ZJIT support you need Rust 1.85.0 or newer and must pass –zjit at build time.
  • ZJIT outperforms the interpreter but is not yet as fast as YJIT; maintainers recommend experimenting but advise caution about production deployment.
  • Ractor received Ractor::Port for inter-Ractor communication, Ractor.shareable_proc/shareable_lambda, Ractor#join/value, and reductions in global-lock contention.
  • Language change: nil no longer calls nil.to_a; logical binary operators at the start of a line continue the previous line similar to fluent dot.
  • Array#rfind and an optimized Array#find were added; Enumerator.produce now accepts an optional size keyword argument.
  • ErrorHighlight now shows code snippets for both the caller and callee when ArgumentError is raised.
  • Pathname and Set were promoted from default gems/stdlib to core classes; String and Regexp received Unicode 17.0 updates.
  • Several Fiber, Thread, IO and Socket APIs gained new hooks or behavior changes (e.g., Fiber#raise(cause:), Fiber::Scheduler hooks, IO.select accepts Float::INFINITY).

What to watch next

  • Performance trajectory of ZJIT in upcoming releases, including promised improvements for Ruby 4.1.
  • Removal of Ractor's 'experimental' status, which the project aims to complete next year.
  • Adoption patterns for Ruby Box in testing, deployment workflows, or as a foundation for any future package-level APIs.

Quick glossary

  • Ruby Box: An experimental isolation feature in Ruby 4.0 that runs definitions in separate namespaces to prevent cross-contamination of patches, globals and loaded libraries.
  • JIT (Just-In-Time) compiler: A runtime compilation system that translates program code into machine code on the fly to improve execution speed compared with interpretation.
  • Ractor: Ruby's actor-like parallel execution abstraction introduced as an experimental feature to provide safe parallelism without shared mutable state.
  • SSA IR: Static Single Assignment intermediate representation, a compiler design choice that can simplify optimizations by ensuring each variable is assigned exactly once.

Reader FAQ

How do I enable Ruby Box?
Set the environment variable RUBY_BOX=1; the feature is provided by the Ruby::Box class.

Is ZJIT ready for production?
The release notes say ZJIT is faster than the interpreter but not yet as fast as YJIT; they encourage experimentation and suggest holding off on production deployment for now.

Do I need Rust to build Ruby with ZJIT?
Yes. The source states Rust 1.85.0 or newer is required to build Ruby with ZJIT support.

Will Ractor remain experimental?
The team aims to remove Ractor's 'experimental' status next year, according to the release notes.

Ruby 4.0.0 Released Posted by naruse on 25 Dec 2025 We are pleased to announce the release of Ruby 4.0.0. Ruby 4.0 introduces “Ruby Box” and “ZJIT”, and adds many…

Sources

Related posts

By

Leave a Reply

Your email address will not be published. Required fields are marked *