Adventures in Metaprogramming: Macros versus Shapeless
summary
Compares concrete implementations: a macro-based macros rewrite code as AST solution that uses Scala reflect to expand a 16–40 line macro, summons a type class Pure to fill constructor params, and extracts field identifiers via pattern-matched trees; versus a shapeless solution that uses LabelledGeneric exposes field names and HLists to derive instances for all case classes. Shows working code (GitHub), reports tradeoffs: macros win for syntactic DSLs and compact expansions, shapeless wins for structural derivation but faces implicit-resolution and compile-time costs.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:14What is metaprogramming
- 4:47Macros
- 8:13Type Classes
- 13:23Shapeless Implementation
- 17:15Better Code
- 20:33Data Validation
- 27:06Analysis
- 30:32TakeHome Points
- 31:56Further Reading
- 33:51Questions








