Performance

Summarized using AI

Keynote: Beyond Ruby3.0

Yukihiro "Matz" Matsumoto • November 08, 2022 • Denver, CO

In the keynote titled 'Beyond Ruby 3.0', Yukihiro Matsumoto, the creator of the Ruby programming language, discusses the advancements and future directions of Ruby following the release of version 3.0. He emphasizes the importance of static typing, concurrency, new syntax, and overall performance improvements as major enhancements in Ruby 3.0.

Key points discussed in the keynote include:

  • Static Typing: Matz highlights the growing trend of static typing in modern programming languages and shares Ruby's approach, which introduces static typing without mandatory type declarations through tools such as Ruby signatures, TypeProf, and third-party static type checkers.

  • Concurrency Enhancements: The introduction of 'Ractors' for concurrent programming allows Ruby to handle CPU-intensive tasks more effectively. Each Ractor operates in an isolated environment, reducing the risk of deadlocks by sharing immutable objects only.

  • New Syntax Features: Ruby 3.0 introduces enhancements like pattern matching and numbered block parameters, making it easier and more intuitive for developers to write concise code.

  • Performance Improvements: Matsumoto discusses the ambitious goal of making Ruby 3.0 three times faster than Ruby 2.0, with tangible improvements noted especially in memory management and method calls, aided by the Just-In-Time (JIT) compiler.

Throughout the presentation, Matz uses practical examples to illustrate these enhancements, including benchmarks showing significant performance gains with Ractors against traditional sequential execution.

He conveys that looking ahead, Ruby 3.1 and beyond will focus heavily on improving tools and performance rather than major language enhancements, underscoring the importance of community-driven development and better user experiences through enhanced coding tools.

In conclusion, Matsumoto expresses optimism for Ruby's future, emphasizing that while the language is well-designed, continuous improvement in tools and performance will elevate the Ruby programming ecosystem. The keynote inspires the community to engage in these improvements, highlighting that better tools are essential for enhancing productivity and the overall developer experience. He reaffirms a commitment to ongoing enhancements in both the language and its tools, ensuring Ruby remains relevant and powerful for developers.

Keynote: Beyond Ruby3.0
Yukihiro "Matz" Matsumoto • November 08, 2022 • Denver, CO

Keynote: Beyond Ruby3.0 by Yukihiro (Matz) Matsumoto

RubyConf 2021

00:00:11.360 Hello, this is Yukihiro Matsumoto, the creator of the Ruby language. Today, I'm going to talk about the future of Ruby, specifically Beyond Ruby 3.0.
00:00:18.080 For the last several Ruby conferences, I've discussed the future direction of Ruby, including the release of Ruby 3.0.
00:00:26.000 Ruby 3.0 was released on December 25, 2020, which was last year.
00:00:31.359 To start, I will summarize what's new in Ruby 3.0. The first major addition is static typing. We are now in an era where modern programming languages like Go, Rust, and Swift are adopting static typing.
00:00:49.520 Even dynamic programming languages like PHP, Python, and JavaScript are incorporating static type annotations through languages like TypeScript, moving towards a more static typing approach.
00:01:06.720 As a result, it seems everyone is leaning towards static typing, so the question for Ruby is, what should we do?
00:01:14.799 To be honest, I do not want to impose strict type definitions. I don't particularly like that because it goes against the DRY principle.
00:01:22.000 Currently, Ruby allows programming without any type declarations; adding these declarations is meant to help compilers work better. If compilers are smarter, we may not need explicit type specifications.
00:01:41.280 However, we still want more precise checks than what dynamic typing allows. We aim to improve type predictions and code completion, enhancing the overall development experience, similar to how developers experience coding in Java with IDEs like IntelliJ or VS Code.
00:01:54.159 We want static type checks without being burdened by rigid type requirements. We accomplish this using tools instead of drastic language enhancements.
00:02:08.479 In Ruby 3, we've added several components that enable static typing without requiring type declarations. The first component is Ruby signatures, the second is TypeProf, and the third involves third-party static type checkers like Steep and Sorbet.
00:02:28.800 Ruby signatures serve as a kind of counterpart to TypeScript; it describes static types in Ruby. It's a language focused on defining types, supporting features such as generics and interfaces.
00:02:43.919 Using these descriptions of core libraries, we can implement type checkers and enhance IDEs for better code completions and type signature pop-ups.
00:02:59.440 TypeProf is another key component. It uses a technology called abstract interpretation, which executes code to analyze types effectively.
00:03:05.680 TypeProf also performs native type checks and can generate Ruby signature files (RBS) for applications.
00:03:14.000 Recently, one of our core developers, Ando, has developed a TypeProf IDE that enables a TypeScript-like development experience using VS Code.
00:03:24.080 At this conference, there is a talk from Ando, who will introduce TypeProf and the IDE in detail.
00:03:31.200 We also have the VS Code Ruby extension that aids in type checking using VS Code.
00:03:39.520 With these tools, your Ruby development experience will be significantly improved.
00:03:46.160 The second major change in Ruby 3.0 is concurrency. We've added an 'async' feature using fibers and Ractor.
00:03:54.240 Async fibers are lightweight concurrency entities suitable for IO-heavy tasks. They provide a Node.js-like experience but use fibers instead of callbacks for context switching.
00:04:04.560 For every IO operation, if another operation blocks, it switches context to idle fibers, making it easier to manage async operations.
00:04:11.680 In a multi-core age, we need solutions for CPU-intensive tasks. We introduced Ractors, which follow the actor model for concurrency.
00:04:22.160 Ractors allow isolated object spaces, making them independent during execution.
00:04:30.000 Ractors can execute asynchronously, avoiding issues such as deadlocks and race conditions.
00:04:39.840 Ractors can share certain immutable objects, such as numbers, symbols, and frozen strings, facilitating communication.
00:04:48.160 Classes and modules in Ruby are immutable, ensuring that access to them is mutually exclusive, which promotes safety.
00:05:01.199 This design helps avoid common concurrency issues.
00:05:07.200 To illustrate Ractor performance, we've a simple benchmark.
00:05:11.120 In our test, the sequential execution of a function took significantly longer than a parallel execution with Ractors.
00:05:20.160 This shows Ractors can significantly improve processing time.
00:05:27.760 For example, in a Fibonacci calculation benchmark, the parallel version with Ractors was about 3.87 times faster.
00:05:35.520 This demonstrates that Ractors effectively enhance performance, especially with practical applications.
00:05:42.080 The third notable improvement in Ruby 3.0 is the introduction of new syntax. Two major features include pattern matching and numbered block parameters.
00:06:00.400 Pattern matching was added in Ruby 2.7 and provides a simpler way to handle data structures.
00:06:08.640 For example, when parsing JSON, pattern matching allows for more straightforward destructuring.
00:06:17.200 In Ruby 3.0, we have introduced one-line pattern matching, enhancing the language's expressiveness.
00:06:28.720 This makes coding more intuitive, leveraging the benefits of pattern matching.
00:06:36.480 Numbered block parameters are another useful addition, allowing for more concise syntax in blocks.
00:06:42.720 For instance, '_1' can represent the first block parameter, making it more straightforward in some contexts.
00:06:54.720 While this feature is incredibly beneficial, I recommend using it wisely to maintain code clarity.
00:07:01.920 In summary, Ruby continues to evolve with enhancements that improve syntax, readability, and productivity.
00:07:10.720 The fourth improvement in Ruby 3.0 encompasses performance optimization.
00:07:18.240 Our performance model revolves around the goal of making Ruby 3 three times faster than Ruby 2.
00:07:30.080 This approach has led us to enhance memory management, access instances, method calls, and significantly improve execution times.
00:07:39.520 With the inclusion of JIT compilers since Ruby 2.6, we have made considerable strides.
00:07:46.720 In benchmarks, Ruby 3.0 demonstrated up to three times faster performance than Ruby 2.
00:07:52.640 For instance, certain benchmarks show Ruby 3 outperforming earlier versions significantly.
00:08:00.720 In conclusion, Ruby 3.0 brought several notable improvements, including static typing, concurrency, new syntax, and enhanced performance.
00:08:10.880 Looking ahead to the future, Ruby 3.1 is slated for release on December 25 of this year. We aim to enhance tools and improve performance further.
00:08:24.640 Ruby is a great language, and I believe so, and I hope you do too. The user experience of Ruby has been greatly enhanced over the years.
00:08:32.640 While enhancements to the language are essential, the importance of effective tools cannot be understated. IDEs and other tools have subverted older practices, bringing a new age of development.
00:08:41.680 As we continue our work in this space, we welcome contributions from both the community and core developers.
00:08:54.240 With contributions, we can build better tools and continue to enhance Ruby development.
00:09:01.920 The second significant area for improvement beyond Ruby 3.0 is performance.
00:09:12.800 Ruby is human-oriented, meaning that while performance is essential, it's not our first priority. We strive to improve Ruby while balancing usability and speed.
00:09:24.080 The challenge we face is that improving performance in Ruby is generally more difficult than in languages designed primarily for speed.
00:09:35.920 Nevertheless, many developers are willing to invest in faster programming languages, so we aim to bridge any performance gaps.
00:09:45.760 As Ruby continues to be widely adopted for web applications and other domains, we recognize the need for enhanced performance.
00:09:54.560 We have aggressive benchmarks and performance measurements, and we are dedicated to improving Ruby in the coming years.
00:10:00.960 Now, Python seeks similar improvements in performance during its ongoing development, indicating a general trend in modern programming languages.
00:10:08.560 Finally, the story here is that as we enhance Ruby, we will provide improvements in its JIT compiler and overall performance.
00:10:16.320 Continuous efforts will ensure Ruby remains relevant and maintains high productivity levels for developers.
00:10:25.520 I appreciate your attention today, and I look forward to shaping the future of Ruby with your support.
00:10:32.000 Thank you for being part of this journey as we explore the boundaries of Ruby and aim for continual progress.
00:10:38.720 And with that, I want to express my gratitude to all the sponsors and the Ruby community.
00:10:44.240 Together, we can enhance Ruby, and together we can build a better world through programming.
00:10:53.440 Thank you once again for your time, and please enjoy the rest of the conference.
00:11:02.600 Goodbye.
Explore all talks recorded at RubyConf 2021
+91