Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
As part of our adoption process of Sorbet at Shopify, we needed an automated way to teach Sorbet about our ~400 gem dependencies. We decided to tackle this problem by generating interface files (RBI) for each gem via runtime reflection. However, this turns out to not be as simple as it sounds; the flexible nature of Ruby allows gem authors to do many wild things that make this Hard. Come and hear about all the lessons that we learnt about runtime reflection in Ruby while building "tapioca".
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In the video "Reflecting on Ruby Reflection for Rendering RBIs," speaker Ufuk Kayserilioglu discusses the challenges and solutions involved in generating Ruby Interface files (RBIs) for gem dependencies at Shopify as part of their adoption process of Sorbet, a static type checker for Ruby. Key Points: - **Introduction to Sorbet**: Kayserilioglu explains that the adoption project began upon his joining Shopify in 2019, focusing on implementing gradual typing in their Rails monolith. - **Problem with RubyGems**: Sorbet does not automatically analyze gem dependencies, which leaves it unaware of the constants and modules exported by gems, complicating the type-checking process. - **Example of Type-checking Challenge**: To illustrate this issue, he presents an example involving a `MyCLI` class subclassing from `Thor`, where Sorbet couldn't recognize `Thor` or its methods. - **Role of Ruby Interface Files (RBIs)**: RBIs declare classes and methods without going into implementation details. This enables Sorbet to type-check user code so long as it knows the structure of the employed gems. - **Automation of RBI Generation**: Given the number of dependencies (over 400 gems), Kayserilioglu emphasizes the necessity of automating the generation of RBI files using Ruby’s reflection capabilities. - **Understanding Reflection**: He describes reflection as the ability to inspect and manipulate class properties and behaviors at runtime, which is essential for creating RBIs efficiently. - **Introspection Techniques**: The discussion includes methods to programmatically gather information about classes, their methods, and relationships to dynamically build the necessary RBI files. - **Challenges of Dynamic Code**: Kayserilioglu highlights potential pitfalls, such as changes in constants during runtime and complications arising from private constants that can lead to errors in understanding class hierarchies. - **Conclusion and Learning**: He concludes that successfully generating RBIs while navigating Ruby's dynamic nature enhances development processes and teamwork. Furthermore, he encourages the audience to explore the open-sourced tapioca gem for more extensive insights. The talk finishes with an invitation for engagement on the topic. Overall, the video emphasizes the innovative use of Ruby’s reflection capabilities to streamline the adoption of Sorbet and ensure thorough type-checking within the Shopify codebase.
Suggest modifications
Cancel