The many shapes of Polymorphism
summary
Argues that which polymorphism a language supports actually changes code shape, comparing Java, Scala, OCaml, Haskell, Go and Rust and showing concrete scala snippets: a Money trait with Fiat and Metal, show/serialize/plus examples, and a web‑service duplication refactor. Demonstrates the adapter pattern to regain type safety, contrasts parametric (generics), subtype polymorphism (inheritance pitfalls, variance issues) and type classes (less boilerplate in Haskell, harder in Scala, cannot add types at runtime), and recommends learning multiple languages to see tradeoffs.
AI-written summary · about
chapters (23)
- 0:00Intro
- 2:15Optical Illusion
- 4:57Why do we use Types in programming languages?
- 5:10A type system is a tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.'
- 6:41The need for polymorphism
- 9:32There are new discoveries in type systems
- 11:01Hypothesis: the way the Polymorphism is used defines the shape of our code
- 16:35Let's start working
- 19:43Let's try (real) subtype polymorphism
- 22:30We're mixing domain logic and behaviour
- 25:02Adapter Pattern
- 32:29Ad-Hoc polymorphism
- 34:02Type class cannot provide new types at runtime
- 35:00Mixing different types of polymorphism
- 35:19Mix subtype polymorphism with generic
- 35:42Mix generic polymorphism with ad-hoc?
- 36:07Polyglot programming
- 37:32Can type classes replace subtype polymorphism?
- 39:55Are type classes only for Functional Programming language?
- 41:13Addendum
- 41:50Thank you for your time Feedback please!
- 44:48Scala is a bridge from OOP to FP world
- 46:04Type inference and subtypes
related talks
48mAncestry of Polymorphism in Clojure
40mWhat Haskell taught us when we were not looking
49mOOP versus Type Classes in Scala
57mDesign Patterns in Dynamic and Functional Languages
41mEvolving Functional Programming Languages
33mRust and Haskell, sitting in a tree
38mWhat Haskell Taught Us When We Weren't Looking
30mWriting extensible functional code
