November 6, 2025

Callbacks vs Coroutines Cage Match

My tutorial and take on C++20 coroutines (2021)

Finally, a guide to tame C++ chaos—if devs stop arguing about old compilers

TLDR: A seasoned dev explains C++20 coroutines in plain English, calling the design useful but messy. Comments joke about outdated compiler versions while splitting between relief at the clarity and frustration that coroutines still demand DIY scaffolding—important because they can simplify complex, stop‑start code if you brave the setup.

A veteran coder drops a tell-all tutorial on C++20 coroutines, calling them a “shiny nugget buried under piles of garbage,” and the crowd shows up with popcorn. The post promises fewer brain-melting callbacks—those stop‑start functions that make event-driven code feel like juggling flaming chainsaws—by using coroutines to pause and resume work more cleanly. But the comments quickly turn into a vibe check: one user snarks, “gcc-10? What is this, 2020?”, poking fun at the tool choices while admitting the write‑up is a solid overview. The mood splits between “finally, something I can read without crying” and “why is this still so hard?” as people wrestle with the author’s take that you must build your own support code because the standard library doesn’t ship the needed bits. Cue running jokes about code indents doing CrossFit and callbacks needing a map just to get home. Some readers praise the plain-English walkthrough and links to cppreference, while skeptics grumble that the design still feels like a maze with a shiny sign at the entrance. The drama? Hope vs. headache: is this the fix for spaghetti code, or just a prettier spaghetti?

Key Points

  • Event-driven C++ code using callbacks often requires splitting logic into multiple functions that cannot share local variables.
  • An example from the Mail Avenger SMTP server shows multiple methods handling the RCPT command due to asynchronous processing needs.
  • C++11 lambdas improve code by enabling local captures but still lead to many functions and deeply nested structures.
  • C++20 introduces coroutines that can suspend and resume execution, facilitating clearer event-driven code.
  • The standard library lacks some required coroutine support types, so developers must implement supporting infrastructure; the article provides a tutorial based on the specification and cppreference.org.

Hottest takes

"gcc-10? What is this, 2020?" — psyclobe
"Nice overview though!" — psyclobe
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.