Avoiding macros with inline and derived
summary
Scala 3 replaces many Scala 2 macros with inline features and compile-time helpers and demonstrates concrete gains: use inline match and inline parameters to erase branches and duplicate expression trees, use summonFrom, erasedValue and constValue to build reliable type-class derivation via product.Mirror and tuples, and emit custom compile errors with compiletime.error. Two real projects show results: an OpenGL shader DSL reduces macros to one necessary macro, and Sauerkraut derives serializers for proto/json/nbt with good performance. Caveats: benchmarks matter, deep recursion and generated-class synthesis still sometimes require macros.
AI-written summary · about
chapters (20)
- 0:00Introduction and welcome
- 1:15Evolution of macros in Scala 2
- 6:32First Scala 3 program and inline basics
- 8:14Inline parameters and by-name semantics
- 13:13Inline pattern matching and compile-time execution
- 16:01Inline zone and type-level computations
- 18:47Compile-time reflection with erased values
- 21:15Literal types and value lifting
- 23:20Summoning givens and error handling
- 26:54Transparent methods overview
- 27:14Deriving type classes in Scala 3
- 30:48Derivation combinators and field access
- 32:14Early lessons from inline projects
- 35:23Literal types and evaluation benefits
- 36:46When not to use inline
- 38:10Synthetic class generation limits
- 40:15Inline limitations and overhead
- 40:59Macros in the new inline world
- 41:20Project examples and performance
- 42:03Q&A and discussion








