Streamtoxication: How a Fluent API turns into a Tangled Mess
summary
Argues that Java streams improve readability but commonly devolve into brittle code by showing concrete examples: summing completed orders (fails with a non-final local, fixed with an AtomicInteger workaround), building a cross product with flatMap, indexing words while profiling a 100 MB string with IntelliJ profiler (finding the match mid-stream thanks to lazy evaluation), race conditions from parallel streams, a working zip/gather demo to preserve indices, toList immutability surprises, and a concise Map.merge one-liner for grouping that replaces three nested collectors.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 1:50Why streams
- 2:54Live coding trap
- 6:46Cross product demo
- 8:54Crowd voting setup
- 10:58Lazy evaluation demo
- 13:07Adding index challenge
- 17:05Parallel stream bug
- 21:00Collect to list issue
- 25:16File parsing exercise
- 27:46Checked exceptions
- 30:17Unparsable lines handling
- 34:42Total income per user
- 38:42Grouping by income
- 41:07Imperative vs functional
- 45:38Functional principles
- 47:44Lambda extraction
- 48:29SQL vs streams
- 50:59Kotlin pitfalls
- 52:49Alternatives to streams
- 53:32Conclusion
