Development

Ruby 4.0 released – but its best new features are not production ready

Published

Ruby 4.0 was released on 25 December, following a tradition of pushing out major versions on Christmas day, and marking its 30th anniversary. Key additions include an experimental isolation feature called Ruby Box, a new just-in-time compiler called ZJIT, and a much improved though still experimental Ractor, used for concurrent programming.

The exact anniversary date for a programming language can be hard to pinpoint, and Ruby is no exception. The first public release was version 0.95 on 21 December 1995, but version 1.0 was not released until 25 December 1996. The language was invented by Yukihiro Matsumoto (“Matz”), as a “genuine object-oriented, easy-to-use scripting language” and an improvement on Perl or Python, according to his own description quoted in the Ruby FAQ.

Ruby is an admired language but its usage is small relative to giants such as JavaScript, Python, Java or C++. The latest StackOverflow survey placed it as used by 6.9 percent of professional developers, ahead of Dart and Swift but behind Kotlin and Rust. Ruby usage is often linked to the Rails application framework, which has some large and influential corporate users including Shopify and GitHub.

Ruby Box is off by default but enabled by an environment variable. Box is a big feature, enabling definitions such as classes and modules to be isolated to a box class. A box also isolates instance variables and global variables. This means that different versions of libraries can co-exist in the same application. The feature was originally called Namespace, but this was changed to avoid confusion with existing Ruby namespaces.

While welcome, Ruby Box is not ready according to some users. “I think in its current state Ruby::Box is a poor implementation of isolated contexts, which exist in JRuby, TruffleRuby, V8, etc. Those have better isolation, they have parallelism (and would be near useless without it) and they have a clearer semantic model” said one, prompting another to state that “Ruby has a tradition of shipping new features in a half-broken or unusable state.”

Another example may be Ractor, first released in Ruby 3.0 but still not production-ready. “We aim to remove its experimental status next year,” say the release notes, meaning during 2026.

Ractor, or Ruby Actor, enables parallel execution. Each Ractor has its own GVL (Global VM Lock) which prevents Ruby code in multiple threads from running concurrently. Ractors on the other hand can run in parallel. Ractor, according to Matz, makes Ruby “a real concurrent language,” but when first released it came with the warning that breaking changes are possible. With 4.0, internal data structures have been improved and a new class introduced “to address issues related to message sending and receiving.”

ZJIT, the new just-in-time compiler, is not enabled by default, perhaps because it is “faster than the interpreter, but not yet as fast as YJIT,” according to the Ruby compiler group, which also states that “you should expect crashes and wild performance degradations.” Nevertheless it is described as a “great new foundation” which will in the end be worthwhile. Developers are invited to “stay tuned for Ruby 4.1.”

The summary, perhaps, is Ruby 4.0 is a release which promises much but delivers little that can be used safely in production. Despite this, Ruby users will be pleased to see that key areas such as concurrency and context isolation are being addressed.