~/talk

Macros vs Types

Talkat Northeast Scala Symposium 2014 · 2014-03-01..03-02· [scala]
slides:none on file

Argues that neither wins alone: combine strong compile‑time types with compile‑time code emission via Scala macros to get readable APIs and fast generated code. Demonstrates macro inlining for arithmetic that removes millions of allocations, implicit macro materialization of type‑class instances via shapeless, statically sized collections using implicits, and an overflow‑checking macro that returns None on detected overflow. Shows three Slick DSL approaches and a yinyang shadow embedding that preserves meaningful types. Works in practice but macros are opaque, slow to debug, and can blow up compile time (type‑level examples slow dramatically around 22→23).

AI-written summary · about

  1. 0:00Start
  2. 0:29Macros vs Types
  3. 2:06Textual code generation
  4. 2:20Textual codegen is too low-tech
  5. 3:23Enter macros
  6. 4:44Use case: Spire Ops
  7. 7:04Use case: Materialization
  8. 9:29Type classes à la Scala
  9. 11:36The dangers of materialization.
  10. 14:42Type computations
  11. 16:11Shapeless
  12. 21:14Let's overthrow the tyranny of types!
  13. 22:27Reasonable use case: Checked arithmetics
  14. 23:08Reasonable use case: WartRemover
  15. 24:31Domain-specific languages
  16. 24:45Use case: Slick
  17. 25:48Lifted embedding (types)
  18. 27:54Direct embedding (macros)
  19. 29:36Shadow embedding (macros + types)
  20. 31:13Our advice
  21. 32:48Types are more declarative, but less powerful
  22. 33:05Macros are more powerful, but less declarative
  23. 33:42Embrace reason, use whatever's simpler
  24. 34:55Three approaches
~/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.