|
Ruby 4.0.0 Released — Yui Naruse of the core team took the helm for this year’s big, and extra special, Ruby release post where we celebrate 30 years of Ruby with the big v4.0! We’re listing a few of the most notable updates below, but it’s worth checking out the post, if only to enjoy the Ruby blog’s new theme.
Yui Naruse
|
|
A New Design for the Official Ruby Site — Unveiled a few days before v4.0, Ruby’s official web site has received more than a lick of paint, with a complete, modern redesign. It’s really well put together and gives off more of Ruby’s friendly vibe than the prior version.
The Ruby Community
|
|
⚡️ RUBY 4.0 IN BRIEF:
-
ZJIT is a new prototype JIT compiler pitched as the 'next generation' of YJIT. It aims to offer extra performance in the long term but isn't considered production ready yet, so it's behind a --zjit flag if you want to test it out.
-
Ruby Box is an experimental isolation feature for separating definitions (monkey patches, globals, class definitions). It's akin to what you might call namespaces elsewhere (and stems largely from a proposal to include namespaces into Ruby) but differs enough to warrant the term 'box'.
-
⚠️ Net::HTTP no longer auto-sets Content-Type. You must now explicitly set it for POST/PUT requests. This is quite a significant, yet subtle, breaking change with potentially negative outcomes, particularly when using API clients that aren't updated for Ruby 4.0.
-
Kernel#inspect's output can now be customized with which instance variables you want to display – potentially useful for hiding sensitive data like tokens.
|
|
-
Logical operators can now start lines (see above) and will continue the expression from the previous line (akin to method chaining with .).
-
Backtraces are cleaner, with internal frames hidden meaning C-implemented methods now show the Ruby source location.
-
Ractors have seen some improvements, but remain experimental for now (though the aim is for the experimental status to be removed later in 2026).
-
Set is now a core class and no longer needs to be autoloaded on use.
-
Array#rfind is a new, more efficient alternative to arr.reverse_each.find.
-
A myriad of performance boosts, like a faster Class#new and faster GC.
-
Ruby 4.0 is now available in the official Ruby Docker images and is how I tested out some of the things above, as I usually wait for the x.0.1 release for my day-to-day work machine... ;-)
|
|
🎄 OK, this really is the final issue of 2025. Our next scheduled issue is on Thursday, January 8 where we'll have even more Ruby 4.0 goodies.
|
|