~/talk

Avoiding macros with inline and derived

Talkat Scala Love in the City 2021 · on Saturday, 2021-02-13· [scala, compilers-and-language-design]
slides:none on file

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

  1. 0:00Introduction and welcome
  2. 1:15Evolution of macros in Scala 2
  3. 6:32First Scala 3 program and inline basics
  4. 8:14Inline parameters and by-name semantics
  5. 13:13Inline pattern matching and compile-time execution
  6. 16:01Inline zone and type-level computations
  7. 18:47Compile-time reflection with erased values
  8. 21:15Literal types and value lifting
  9. 23:20Summoning givens and error handling
  10. 26:54Transparent methods overview
  11. 27:14Deriving type classes in Scala 3
  12. 30:48Derivation combinators and field access
  13. 32:14Early lessons from inline projects
  14. 35:23Literal types and evaluation benefits
  15. 36:46When not to use inline
  16. 38:10Synthetic class generation limits
  17. 40:15Inline limitations and overhead
  18. 40:59Macros in the new inline world
  19. 41:20Project examples and performance
  20. 42:03Q&A and discussion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.