Exercises in Style
summary
Implements the same term-frequency program in nine concrete styles (procedural, functional, object, continuation/callback, map-reduce, etc.), with working code examples in Python: a terse code-golf one-liner that runs in minutes and leaks file descriptors under load, procedural and functional pipelines that compose cleanly, an object-oriented version that encapsulates state, and a map-reduce chunks variant that parallelizes by chunking the file. Claims that comparing real implementations (33+ styles planned, code destined for GitHub) teaches design tradeoffs better than abstract definitions.
AI-written summary · about
chapters (12)
- 0:00Intro
- 6:12Programming Styles Ways of expressing tasks Exist at all scales Recur in multiple scales Codified in PLS
- 7:51Why Are Styles Important? Many Common vocabularies Basic frames of reference Some better than others Depending on many things!
- 8:02Why Are Styles Important? Many Common vocabularies Basic frames of reference Some better than others - Depending on many things!
- 16:25Main Characteristics No abstractions Heavy control flow
- 21:54Main Characteristics No [named] abstractions Very few [long] lines of code Advanced libraries / constructs
- 24:49Main Characteristics Procedural abstractions maybe input, no output Shared state Commands
- 27:29Main Characteristics Function abstractions f: Input → Output No shared state Function composition fºg
- 30:14Main Characteristics Functions take one additional parameter, f called at the end * given what would normally be the return value plus the next function
- 33:57Main Characteristics Things, things and more things! Capsules of data and procedures Data is never accessed directly Capsules say "I do the same things as that one, and more!"
- 35:18Main Characteristics (Similar to #6) Capsules receive messages via single receiving procedure
- 37:19Main Characteristics Two key abstractions: map(f, chunks) and reduce(g, results)








