What Is New in Ruby 3.5
| Category | Key Changes |
|---|---|
| New Features | IRB debugger integration, Pattern matching enhancements, New socket API |
| Improvements | Faster require, Better error messages, Ractor updates, Regexp optimizations |
| Performance | YJIT enhancements, GC improvements, VM optimizations |
| Compatibility | String methods update, Unicode/Emoji version bumps |
How does IRB's new debugger integration change the debugging experience?
IRB now includes a built-in debugger that eliminates the need for external gems like debug.gem. You can set breakpoints directly in your code using binding.irb and get full debugging capabilities within the IRB session.
This integration means you get breakpoints, step debugging, and inspection tools without additional dependencies. For daily development, it streamlines the workflow significantly compared to switching between different debugging tools.
What pattern matching enhancements should developers know about?
Pattern matching now supports the in operator within rescue clauses, allowing you to match exceptions more precisely. This gives you cleaner error handling code when dealing with specific exception types and patterns.
begin
# risky code
rescue in [ErrorClass, {message: /pattern/}]
# handle specific error pattern
end
The syntax feels more natural for Rubyists who've been using pattern matching in other contexts, bringing consistency to error handling.
How much faster is require in Ruby 3.5?
The require method has been optimized to be faster, particularly for large applications with many dependencies. While exact benchmarks vary, the improvements are most noticeable in applications with complex dependency trees.
These optimizations reduce the overhead of loading files, which means your application starts up quicker. For development cycles with frequent restarts, this adds up to meaningful time savings throughout the day.
What socket API changes affect network programming?
Ruby 3.5 introduces a new Socket.tcp API that provides a more straightforward interface for creating TCP connections. The new method accepts keyword arguments for better readability and control over connection parameters.
# New syntax
Socket.tcp(host, port, connect_timeout: 5, resolv_timeout: 3)
This update makes socket programming more approachable while maintaining backward compatibility with existing code that uses the traditional API.
Which performance improvements matter most for production applications?
YJIT continues to see significant enhancements in Ruby 3.5, with improved compilation strategies and better memory handling. The garbage collector also gets optimizations that reduce pause times and improve overall throughput.
Regexp matching has been optimized for better performance with certain patterns, which benefits applications doing heavy text processing. These combined improvements should yield tangible benefits for most production workloads without requiring code changes.
FAQ
Do I need to install debug.gem separately with Ruby 3.5?
No, the debugger functionality is now integrated directly into IRB. You can use binding.irb for breakpoints and debugging without any additional gems.
Will my existing pattern matching code break in Ruby 3.5?
No, all existing pattern matching code will continue to work. The new rescue in syntax is additive and doesn't change existing behavior.
How significant are the require performance improvements?
The improvements are most noticeable in large applications with many dependencies. While exact numbers vary, applications with complex dependency trees should see faster load times.
Does the new Socket.tcp API replace existing socket methods?
No, the new API is additive and provides a more modern interface. All existing socket code will continue to work unchanged.
Are there any breaking changes in string methods?
Some string methods like String#chr and String#ord now handle invalid byte sequences differently, but these are edge cases that shouldn't affect most applications.