No Static Types? No Problem!
summary
A small Rails app called the cookie_cutter app has a rake batch that sometimes passes a recipient string instead of a Person and charges payment before crashing; Sorbet catches that mismatch as a runtime and editor error by failing at the method call, RBS/YARD give editor hints, and the new literal gem enforces checks at initialization. Fixes shown include coercions (string → Person, HashWithIndifferentAccess), GlobalID lookups, a refactored checkout object that validates in initialize, and the null object pattern to avoid late failures.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 15:07What is a type in Ruby
- 27:20Static type systems overview
- 35:10Caller vs static typing
- 48:15Break and return hook
- 52:31Ruby type errors in production
- 1:00:20Data coercion techniques
- 1:18:58Object design and encapsulation
- 1:33:22Polymorphism and null objects
- 1:43:22Static typing pros and cons
- 1:48:44Q&A
related talks
37mChecking Your Types: An Overview of Ruby's Type System
31mStatic Type Checking in Rails with Sorbet
30mSorbet at Grailed: Typing a Large Rails Codebase to Ship with...
22mYou and your type[s] aren't welcome here
35mThe worst Ruby codes I've seen in my life
25mA Dangerous Game: Safety in Ruby
41mSorbet: A type checker for Ruby 3 you can use today!
30mDucks and monads: wonders of Ruby types
