Unveiling RubyConf 2022: Matz on Performance
Table of Contents
- Introduction to Matz
- Ruby's Performance Concerns
- Improvements in Ruby's Performance
- Ruby's Popularity and Language Choice
- Prioritizing Performance in Web Applications
- Ruby Community's Contribution
- What's New in Ruby 3.2
- Ruby on WebAssembly (WASM)
- YJIT Compiler
- Syntax Suggestions and Error Highlighting
- Improved AST (Abstract Syntax Tree)
- Regenerating Original Programs from AST
- Ruby's Goal: Making Users Happy
- Conclusion
Introduction to Matz and Ruby
Matz, the creator of the Ruby programming language, is a well-known figure in the Ruby Community. As a professional programmer, he has contributed significantly to the Japanese open-source company netlab.jp. Though Matz couldn't attend the conference in person due to a recent COVID infection, he recorded a keynote presentation to share his thoughts about Ruby's performance. In his keynote, Matz highlights the misconception surrounding Ruby's speed and discusses the language's popularity and priorities.
Ruby's Performance Concerns
For many years, people have questioned the performance of the Ruby language. The common claim has been that if Ruby were faster, more people would choose it. However, despite numerous performance improvements over the years, Ruby has not become the top choice for those seeking higher speed. Matz explains that performance is not always the first priority when selecting a programming language, especially for web applications. Popular web services like Shopify and GitHub are implemented in Ruby, even though there may be faster alternatives available.
Improvements in Ruby's Performance
Ruby has made significant performance improvements throughout its history. Versions like Ruby 1.8 and Ruby 1.9 introduced optimizations such as improved call frames, a new version machine code named YARV, and generational and Incremental garbage collectors. These improvements have made Ruby much faster compared to its earlier releases. However, Matz emphasizes that speed alone doesn't persuade individuals to choose Ruby as there are always faster languages, especially those natively compiled.
Ruby's Popularity and Language Choice
Despite its performance concerns, Ruby has gained popularity and won the hearts of a vast community. Matz explains that performance is not the sole factor in language selection. People choose Ruby for its community, ease of use, and the joy it brings to developers. The Ruby Community contributes significantly to the language's growth and improvement. It is a generous, friendly, and collaborative community that works together to make Ruby better.
Prioritizing Performance in Web Applications
Matz highlights the significance of performance in certain scenarios, especially when it can have a massive financial impact. For web services that require numerous hosts to serve, even a small performance improvement in Ruby can save significant costs. Matz cites an example where a 10% increase in Ruby's speed could save businesses more than 80K USD per year. Thus, performance becomes a priority for web application developers when significant financial benefits are at stake.
Ruby Community's Contribution
The Ruby Community plays a crucial role in driving Ruby's performance improvements. Matz explains that the focus is not on catering to the requirements of total strangers who prioritize speed above all else. Instead, the community strives to improve Ruby for its own members, who attend conferences like RubyConf and actively contribute to the language's development. Their contributions increase the joy and wealth of the Ruby language, creating a better world for Ruby users and enthusiasts.
What's New in Ruby 3.2
Ruby 3.2 brings exciting new features and improvements that enhance the language further. Matz introduces some of these key additions:
- Ruby on WebAssembly (WASM): The entire Ruby virtual machine can now be compiled into WASM, allowing the execution of Ruby code in a browser without restrictions. This opens up new possibilities for fully implementing Ruby in the browser.
- YJIT Compiler: Previously sponsored by Shopify, the YJIT compiler has been entirely rewritten in Rust. This rewrite aims to support new objectives, such as better support for ARM64 architecture. The performance gains from YJIT have significantly improved Ruby on Rails applications.
- Syntax Suggestions and Error Highlighting: The introduction of syntax_suggest and error_highlight in Ruby 3.2 enhances the developer experience. These features provide better error messages, highlighting, and improved code completion.
- Improved AST: The Abstract Syntax Tree (AST) parser now holds tokens from the program, enabling the regeneration of the original programs from AST information. This feature allows developers to understand the original code, including comments and spaces.
- Better Tooling Support: Ruby's AST improvements Align with the need for better productivity tools. The language's parsing capabilities have become more error-tolerant, allowing the parsing of half-baked Ruby programs effectively. These improvements make Ruby development more productive and support the creation of new tools.
Ruby's Goal: Making Users Happy
Matz emphasizes that the sole purpose of Ruby's development is to make users happy. The joy experienced by Ruby users is the language's greatest value. The Ruby Community actively works together, contributing to the language's evolution and spreading happiness. Matz is proud to be a part of this generous and helping community, which has successfully increased world joy.
Conclusion
Matz concludes his keynote by expressing his gratitude to everyone in the Ruby Community. He encourages attendees to enjoy the rest of the conference and draw inspiration from fellow Ruby enthusiasts. Matz promises to respond to queries and engage with the community through social media, working towards a better and happier world for Ruby developers.
Highlights
- Ruby's performance concerns have been prevalent despite significant improvements over the years.
- Performance is not always the primary factor in language selection, especially for web applications.
- Ruby's popularity is driven by factors beyond performance, such as its supportive community and ease of use.
- Performance becomes crucial when it can result in significant financial benefits, as seen in web services.
- Ruby 3.2 introduces exciting features like Ruby on WebAssembly, YJIT compiler, and improved tooling support.
- The Ruby Community plays a critical role in the language's growth and improvement, contributing to increased joy.
- Matz's vision is to Create a better world through Ruby, where users find happiness and benefit from its features and community.
FAQ
Q: Is Ruby a slow programming language?
A: Despite historical claims about Ruby's performance, significant improvements over the years have made it fast enough for most use cases, particularly web applications.
Q: Why do web services like Shopify and GitHub use Ruby despite its performance concerns?
A: Ruby's popularity stems from factors beyond performance, such as the supportive Ruby Community, ease of use, and the joy it brings to developers. These web services find Ruby fast enough to serve their needs effectively.
Q: What are the new features in Ruby 3.2?
A: Ruby 3.2 introduces Ruby on WebAssembly (WASM), a rewritten YJIT compiler, syntax suggestions, error highlighting, improved AST, and better tooling support.
Q: How does the Ruby Community contribute to the language's development?
A: The Ruby Community actively contributes to the language's growth and improvement through conferences, collaboration, and code contributions. Their generous and friendly nature has made Ruby a thriving community-driven language.
Q: What is Matz's goal for Ruby as its creator?
A: Matz's primary goal is to make Ruby users happy, spreading joy through a language that brings people together and makes their lives better.