Generic Swift: It Isn’t Supposed to Hurt
summary
Argues for concrete code first, then introduce generics only when needed, and demonstrates a composable networking stack built from tiny transport components (URLSession wrapped into a transport wrapper because of a compiler bug), JSON Decodable models, and small request structs that hold closures instead of protocol-heavy interfaces. Shows how ID type wrappers prevent accidental mixing of identifiers, explains why associated types block putting protocols in arrays, and replaces mocks with swappable transports and function lists — the design works but exposes compiler rough edges.
AI-written summary · about
chapters (11)
- 0:00Introduction to Swift generics
- 1:17Protocol-oriented programming basics
- 6:59Real-world generic networking stack
- 16:51Extracting transport protocols
- 21:31Understanding existential types
- 25:54Solving ID type problems
- 33:06Refining fetch requests
- 37:00Concrete request design
- 40:37Equatable and custom equality
- 47:18Protocols as reusable algorithms
- 51:31Swift 6 wishlist and Q&A
related talks
46mGeneric Swift: It Isn't Supposed to Hurt
20mHow Not to Write Swift
30mLeveraging Swift's Type System
48mLearning From Our Elders: Applying functional insights without losing Swift
27mGeneric Protocols and Associated Types - Power Tools for Unit Testing
40mPractical Generics in Swift
40mLeveraging Swift’s Type System
18mSilver Bullets in Swift
