Zero Cost Abstractions Eliminating Runtime Overhead in Scala
summary
Concrete claims and code: a Scala new-type macro generates zero-cost newtypes and subtypes (with a Scala 2.12 inline workaround for primitive boxing), a Coercible-style type class enables constant-time coercions (no per-element map), and an @cached macro caches polymorphic instances so implicit summons avoid allocations — demonstrated with an Either functor example. A derivable project implements zero-cost generic programming that benchmarks ~20% faster than Shapeless and performs nearly identically to hand-written code.
AI-written summary · about
chapters (9)
- 0:00Start
- 0:12ZERO COST ABSTRACTIONS
- 2:41WARNING
- 8:46NEWTYPES: A MOTIVATION
- 15:39NEWTYPE: FIRMALIZING THE APPROACH
- 17:23NEWTYPE TYPE SEMANTICS
- 18:57NEWTYPE: EXTENSION METHODS
- 31:39GENERIC PROGRAMING SHAPELESS
- 41:27DERIVING NEW TYPE CLASS INSTANCES
related talks
52mBake Real-life Apps with a Handful of Free, Coproducts & Types
49mFree vs Tagless Final: What, Why, When?
33mThe state of Scala as a platform for statistical computing
46mBeing Creative with Genetic Algorithms and Typeclasses
52mCategory-parametric Programming
54mWhy Netflix ❤'s Scala for Machine Learning
01h 20mA Practical Introduction to Haskell GADTs
01h 39mIsomorphic Reasoning: Counting with Types Part 1
