Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Called “downcase” on nil? Forgot to return the right object in one of your logic branches? Called “first” on a String instead of an Array and spent half an hour trying to figure out why a single character was getting passed around everywhere? At Grailed, these situations were not uncommon. We are the largest marketplace for luxury men's fashion, with over 7 million users, and a growing Rails codebase that spans hundreds of thousands of lines. Before typing, changes to core interfaces often required creative grepping, modification of type checking unit tests, and updating brittle type documentation. Ever since we started gradually typing our codebase with Sorbet, we’ve been able to make intrusive changes faster and confidently. In this talk, we’ll walk you through our prior art, challenges, learnings, and big benefits of typing our codebase.
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 this talk presented at RubyConf 2021, Jose Rosello, a staff engineer at Grailed, discusses the integration of Sorbet, a gradual static typing system for Ruby, into their extensive Rails codebase. With Grailed being a peer-to-peer luxury fashion marketplace with over 7 million users and a growing codebase from 30,000 lines to over 150,000 lines in just a few years, the need for stronger type safety became apparent. The presentation highlights several critical points regarding the transition from dynamic to static typing: - **Context and Motivation**: Grailed's transition to static typing was largely driven by a developer's frustration with null pointer exceptions and type issues in a dynamically typed language. - **Benefits of Static Typing**: Static typing allows for more confident refactoring and reduced errors, improving both code legibility and documentation reliability. The reliance on comments for documenting types can lead to stale and misleading information. - **Introduction to Sorbet**: Sorbet allows developers to gradually adopt static typing through its flexible enforcement levels (false, true, strict, strong). Rosello emphasizes that the syntax allows for valid Ruby code without a transpilation step. - **Runtime Checks**: Unlike traditional static typing, Sorbet provides runtime checks to catch type errors that arise from dynamically typed code calling typed methods, reducing the likelihood of production errors. - **Handling Dependencies**: Sorbet utilizes Ruby Interface Files (RBIs) to enable type checks for external libraries and gems, promoting speed and practicality without needing to alter the original gem code. - **Rolling Out Sorbet**: The adoption process included generating RBIs, addressing dynamic imports, and utilizing tools like Tapioca for better RBIs generation. Key metrics show an impressive uptake, with only 8% of code files remaining untyped. - **Challenges**: Rosello discusses challenges such as ensuring types for dynamic Rails components, dealing with legacy code, and managing a gradual typing approach. He acknowledges the limitations of Sorbet and encourages the community to embrace its continued development for improvement. - **Conclusion**: After two years, Sorbet has greatly enhanced code quality at Grailed, promoting clearer documentation, safer code changes, and overall better developer experience. Jose concludes by affirming the positive impact of Sorbet and mentions that Grailed is hiring, inviting interested candidates to learn more. Overall, this talk combines practical insights with technical analysis, demonstrating the substantial benefits of incorporating static typing into dynamically typed languages like Ruby.
Suggest modifications
Cancel