“State Machines Battlefield - Naive vs STL vs Boost”
summary
Benchmarks compare naive if/else and switch (about 64 lines of code, very well inlined) versus object‑oriented vtable approach (about 220 lines of generated assembly, heap allocations) and STL approaches: std::variant inlines well on Clang but not GCC, coroutines use heap and show poorer optimization. Boost.Statechart generates ~3k assembly and is slow, MSM is expressive but has very long compile times; Boost.SML gives a readable transition table, configurable compile‑time dispatch and the best compile/runtime/size balance.
AI-written summary · about
chapters (10)
- 0:00The problem with state
- 3:14Introduction to state machines
- 5:31Naive implementation: If-else
- 10:09Naive implementation: Switches
- 12:28State pattern
- 16:18Modern C++: std::variant
- 23:52C++20 Co-routines
- 36:55Boost libraries: MSM and Chart
- 44:01SML library
- 52:52Benchmarks and conclusion
related talks
05m[BOOST].SML STATE MACHINE LANGUAGE
01h 13mModernizing Finite State Machines in C++ - Empower Simplicity & Boost Performance With std::variant
57mThis Videogame Programmer Used the STL and You Will Never Guess What Happened Next
59mSoftware Engineering Is About Tradeoffs
01h 26mLow-Latency Trading Systems in C++: Templated Meta-State Machines in HFT
01h 08mTemplate Meta-State Machines, Madness and Shannon
46mWhat C and C++ can do and when do you need Assembly?
22mEffective replacement of dynamic polymorphism with std::variant
