Expression-based Programming for Better Code?
summary
Claim: treating statements like expressions and moving each control block into its own function yields smaller, clearer C++ code that leverages RVO/NRVO, tail call elimination and ranges/projections. Evidence: a real project (Infizz on GitHub) refactors a giant switch/while into per-case functions and lambdas, shaving about 25 lines and simplifying control flow. Tools and observations: inspection of GCC/Clang assembly, NRVO warnings, benchmarks showing similar binaries for idiomatic ranges, and caveats—undefined behavior risks, GCC sometimes misses NRVO, and tail calls depend on optimization flags.
AI-written summary · about
chapters (7)
- 0:00Expression-based programming intro
- 10:00Return value optimization in C++
- 21:08Tail call elimination and recursion
- 30:09Expressions vs statements
- 37:44Switch and loops as expressions
- 51:03Refactoring control structures
- 59:55Q&A
related talks
01h 04mFunctional C++ For Fun And Profit
01h 31mFunctional Programming in Modern C++: The Imperatives Must Go!
01h 02mFunctional C++
49m“Applying functional programming in code design"
49mThe Evolution of Functional Programming in C++
01h 03mHigher order functions for ordinary C++ developers
01h 09mThe Definitive Guide to Functional Programming in Cpp
44mFunctional Programming You Already Know
