Typing in Java, Kotlin and Scala
summary
Compares Java, Kotlin and Scala on concrete examples: Java requires casts for a generic Layout.rotate and loses type precision after compilation, Kotlin uses Kotlin extension functions plus reified inline generics to return a Layout<Vertical> from a Layout<Horizontal> without casts, Scala uses Scala covariance/contravariance (+/−) to model box relationships and enforces safe render signatures, all three suffer JVM type erasure so solutions use TypeTags/shapeless or compiler tricks; examples and bytecode/benchmarks live in the GitHub repo.
AI-written summary · about
chapters (20)
- 0:00Intro
- 0:27Disclaimers
- 1:11Bias
- 1:40Kotlin
- 5:12Refactor
- 5:28Rotate
- 8:35Type Parameters
- 10:24State
- 11:28Type Orientation
- 14:55Scala Type Orientation
- 17:06Covariance
- 18:50Rerender
- 21:25Variants
- 26:48Type erasure
- 26:58Generic parameters
- 28:25Type erasure strategies
- 30:22Why is this important
- 33:10References
- 34:32Reified Generics
- 37:18Erasure








