Exciting Enhancements in Ruby 3.3: What You Need to Know
Written on
Chapter 1: New Features and Enhancements in Ruby 3.3
Ruby 3.3 brings a wealth of new features and improvements designed to enhance the programming experience. Here’s a look at what’s new:
Section 1.1: The Prism Parser
One of the standout introductions in Ruby 3.3 is the Prism parser. This parser serves as a default gem and is designed to be portable, error-tolerant, and maintainable. It functions as a recursive descent parser for Ruby and can replace the existing Ripper parser. Noteworthy methods are included in the Prism API, and you can enable debugging by using ruby --parser=prism or setting RUBYOPT="--parser=prism".
Section 1.2: Changes to the Parser Generator
The Bison parser generator has been replaced with the Llama LALR parser generator. This change enhances maintainability and supports parameterization of rules, such as ?, *, and +.
Chapter 2: Performance Improvements
Ruby 3.3 has made significant strides in performance, especially in YJIT (Yet another Just-in-Time compiler). The enhancements lead to:
Video: What's New In Ruby 3.3 - YouTube
This video provides an overview of the new features and performance improvements in Ruby 3.3.
- Enhanced support for splat and rest arguments
- Improved compilation of calls with optional arguments
- Optimized basic methods and slightly better compilation speed compared to Ruby 3.2
- Enhanced memory management and automatic threshold adjustments based on application characteristics
- Code garbage collection (GC) is now disabled by default
Section 2.1: Introducing RJIT
Ruby 3.3 also introduces RJIT, a pure-Ruby Just-in-Time compiler that replaces MJIT. This feature supports x86–64 architecture on Unix platforms and is primarily experimental, intended for development tasks.
Section 2.2: The M:N Thread Scheduler
The new M:N thread scheduler allows for managed threads, thus reducing the costs associated with thread creation and management. While this feature is disabled by default on the main Ractor, it can be activated through specific environment variables.
Chapter 3: Compatibility and Miscellaneous Changes
Ruby 3.3 comes with several compatibility changes and deprecations.
- Deprecations: Calls without arguments in blocks with no regular parameters are deprecated.
- Removed Environment Variables: The outdated RUBY_GC_HEAP_INIT_SLOTS variable has been eliminated.
- Standard Library Updates: The ext/readline library has been retired in favor of the pure Ruby implementation, reline. Additionally, there have been updates and enhancements to the standard library.
Stay tuned as we delve deeper into Ruby 3.3 and explore its features!
Video: Install Ruby 3.3 & Rails 7.1 on MacOS (2024) - YouTube
In this tutorial, learn how to install Ruby 3.3 and Rails 7.1 on MacOS, ensuring you're up to date with the latest tools for development.