It’s official, Ruby 3.3 has arrived, bringing a wave of excitement to the Ruby community.
In this blog, we will go through the latest features, enhancements, and bugfixes introduced in the Ruby 3.3
Ruby 3.3 introduces Prism, a new, portable, and maintainable parser offering improved reliability and performance.
It is now the default gem and we can use it in place of Ripper.
Prism is ready for production use and already being used by
Rubocop, and many others.
- Support for splat and optional parameters in methods has been improved.
- Instead of making costly function calls for key methods like
Kernel#block_given?and more, YJIT embeds the code directly into the calling function. This will make core tasks like comparisons and type-checks become lightning-fast.
- Inlines methods like
- Faster compilation than Ruby 3.2
RubyVM::YJIT.enablehas been introduced, which allows us to enable YJIT at runtime.
- Rails 7.2 will enable YJIT by default by using
RJIT is an experimental Just-In-Time compiler written in pure Ruby. It replaces the current implementation of MJIT. It doesn’t require any external compilers like Rust or C, making it more portable and potentially easier to maintain, but it’s currently limited to the x86-64 architecture on Unix platforms.
While RJIT holds promise for future performance improvements, it’s essential to remember that it’s still in its early stages and not recommended for production use. YJIT remains the default and preferred option for most Ruby 3.3 users
M:N Thread Scheduler
The M:N thread scheduler, introduced in Ruby 3.3, is a significant improvement to how our Ruby programs handle concurrent tasks. it is introduced to improve thread and ractor performance and here, M refers to number of ractors and N refers to the number of native threads.
IRB has got a lot of enhancements in the Ruby 3.3 release. Some of the major enhancements are
- Integration of debug gem with IRB by introducing
irb:rdbgsession, which will allow to use all debug commands without exiting the IRB session.
- Customizing the Dropdown UI with
- Introduced history command to display all stored input history.
- Pager support for
- We can now omit the return value with
;. It will make easier to inspect the long outputs.
show_sourcecommands now support
-sflag to get the method’s super definition and it can now display private methods too.
Ruby 3.3 added a new warning category for performance related concerns. This category would be disabled by default and can be enabled in development.
Ruby 3.3 introduces range#overlap?(range) method to compare two ranges and see if they overlap each other.
Range#reverse_each can now process beginless ranges with an Integer endpoint and raises TypeError for endless ranges.
Ruby 3.3 fixed a bug in the Range#size method related to rational endpoints, ensuring accurate counting.
Duplicate Keyword Argument
Ruby 3.3 fixes inconsistent warnings for duplicate keyword arguments. We will now get a warning when overwriting a previously provided keyword argument.
Ruby 3.3 optimizes String.dup to match the speed of String#+, allowing developers to choose based on preference without sacrificing performance.
Refinement#refined_classhas been deprecated in favor of
Kernel#openand IO support for subprocess creation and forking were deprecated because of multiple security issues. Check out the following blog to learn more about this.
Following methods are deprecated in favor of using
- Calling a method called
itwithout args has been deprecated and will show a warning.
itwill be a reference to the first block parameter in Ruby 3.4.