Type Classes in C#
summary
Shows how to get the benefits of C# “type classes” (a pattern not built into the language) to have both clean, generic code and runtime efficiency. Presents example code (inspired by Vlasin) that looks like ordinary code, works with arbitrary value types and collections, and approaches hand-written performance while beating interface-based solutions; also covers allocation-free LINQ, LINQ without per-iteration delegate calls, and a generic element-wise collection comparison.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 1:03Two evils dilemma
- 6:10Type classes concept
- 9:04Goal of type classes
- 10:30Summing array elements
- 15:50Virtual calls problem
- 17:38Performance breakthrough
- 20:48Zero-size struct trick
- 23:03Type classes implementation
- 25:52Type classes future
- 27:41Overflow handling
- 29:27Indexed collections
- 34:09Iterable collections
- 37:25Iterator performance
- 40:37Production use case
- 41:42Sequence comparison
- 46:46Reference types handling
- 47:51LINQ alternatives
- 50:17Performance tips
- 51:41More use cases
- 52:48Q&A
