Credit: Jorge Aguilar / How To Geek | Ruby
Published 9 minutes ago
Aggy is a veteran writer and editor in the technology and gaming space. Having served as a Managing Editor for high-traffic digital publications, alongside being an editor and consultant for over a dozen sites. Aggy’s published work spans a wide and respected array of tech and gaming outlets, including WePC, Screen Rant, How-To Geek, Android Police, PC Invasion, and Try Hard Guides.
Beyond editorial work, Aggy’s direct experience in the tech sphere extends to app development. Aggy has published two games under Tales and is always eager to learn and do more. He also likes working on computers and researching in his spare time.
He knows about Windows, Linux, Audio, Video, and much more.
Sign in to your How-To Gee…
Credit: Jorge Aguilar / How To Geek | Ruby
Published 9 minutes ago
Aggy is a veteran writer and editor in the technology and gaming space. Having served as a Managing Editor for high-traffic digital publications, alongside being an editor and consultant for over a dozen sites. Aggy’s published work spans a wide and respected array of tech and gaming outlets, including WePC, Screen Rant, How-To Geek, Android Police, PC Invasion, and Try Hard Guides.
Beyond editorial work, Aggy’s direct experience in the tech sphere extends to app development. Aggy has published two games under Tales and is always eager to learn and do more. He also likes working on computers and researching in his spare time.
He knows about Windows, Linux, Audio, Video, and much more.
Sign in to your How-To Geek account
The Ruby programming language continues its tradition of delivering major updates on Christmas Day, announcing the release of Ruby 4.0.0, which introduces two massive new experimental features: the isolation mechanism known as Ruby Box and the next-generation just-in-time compiler, ZJIT.
The biggest architectural change arriving with version 4.0 is definitely Ruby Box. This new experimental feature has strict separation for definitions loaded within the box. If you’ve ever wrestled with complex dependency issues or had a rogue monkey patch mess up your global environment, you know how crucial isolation can be. Definitions loaded inside a Ruby Box are isolated from other boxes, meaning they can separate out global or class variable changes, class definitions, and even loaded native libraries.
The Ruby team suggests using boxes to run test cases where you might need monkey patches without worrying about those changes leaking out and affecting other tests. You could also use this feature as a foundation for implementing blue-green deployment strategies on an application server, running parallel web app boxes in a single Ruby process. This is a powerful low-level API, and I wholly expect to see high-level package management tools use this heavily in the future.
On the performance front, the developers are already looking beyond YJIT with the introduction of ZJIT, a brand-new just-in-time compiler. ZJIT is designed to be the next step forward in Ruby performance, aiming for a much higher performance ceiling by using things like SSA IR and bigger compilation units. The team is also trying to make ZJIT a more traditional method compiler, which should encourage more external contributions from optimization experts.
Right now, ZJIT is still highly experimental. While it is measurably faster than the standard Ruby interpreter, it hasn’t quite caught up to YJIT yet. I would say the biggest problem is that you shouldn’t rely on it for production workloads just yet, but you can certainly experiment with it now if you have Rust 1.85.0 or newer installed to build it. We’ll have to wait until Ruby 4.1 to see if ZJIT truly becomes the performance champion the team is aiming for.
Beyond the new experimental features, we’re seeing significant stability and performance boosts for Ractor, Ruby’s mechanism for parallel execution. Ractor was introduced as experimental in Ruby 3.0, and the team is working to remove that tag in the next year. The update includes major internal optimizations designed to improve parallelism. Ractors now share less internal data, which reduces CPU cache contention when running multiple threads simultaneously.
The Ractor synchronization mechanism has also been updated with the introduction of a new class called Ractor::Port. This class provides explicit methods like receive and send for communication between Ractors. This addition results in the removal of older, less intuitive methods like Ractor.yield and Ractor#take. Developers also get new methods like Ractor#join and Ractor#value, which mirror the familiar behavior of threads when waiting for a Ractor to terminate. The new Ractor.shareable_proc also makes passing logic between parallel execution units much easier.
Ruby 4.0 also brings several quality-of-life updates to the core language and built-in classes. For instance, the language will now allow logical binary operators like && or || to continue the previous line if they appear at the beginning of a new line, similar to how the fluent dot operator works.
One feature I really like is the improvement to ErrorHighlight. When an ArgumentError is raised, the debugger now displays code snippets for both the method call and the method definition. This feature is huge for debugging, letting you instantly see where the wrong number of arguments was passed and where the method was defined, all in one clear snippet.
The core classes received a privacy-focused update as well. The Kernel#inspect method now checks for a private method called instance_variables_to_inspect. Also, two commonly used components, Pathname and Set, are being promoted from default gems to core classes.
This is a big update, but that’s what is to be expected with 4.0; you can grab the latest tarball or zip from the official site today.
Source: Ruby