March 25, 2026
Yield my beer
Looking at Unity made me understand the point of C++ coroutines
Unity’s ‘yield’ hack sparks C++ coroutine chaos and cheers
TLDR: A dev found a real use for C++ coroutines by copying Unity’s simple “wait a frame” trick for game effects. Commenters split between praising the hack, calling C++ coroutines too hard and memory-hungry, demanding better tooling in future C++, and flexing with DIY assembly solutions — because of course.
A developer finally “gets” C++ coroutines after seeing how Unity’s C# uses them to script quick, flashy effects — basically pausing a scene and picking it up next frame with a tiny “yield.” The crowd? Split between applause and eye-rolls. One camp cheers Unity’s scrappy trick of using yield return null as a stand-in for “wait one frame,” calling it a clever way to tame the chaos of game time. Another camp shouts that C++ coroutines are still a nightmare to wire up, with too much low-level scaffolding and not enough real-world examples. The nostalgia police pile on, groaning that Unity is “stuck on an ancient version of C#,” while pragmatists shrug: if it works, it works.
Performance hawks swoop in hot: some argue C++’s flavor is “stackless” and can lead to extra memory churn, while the hardcore flex that you can write your own old-school, “stackful” coroutines in a few assembly lines — because of course someone brought assembly to a coroutine fight. Others beg the standards gods for C++26 to ship training wheels out of the box. Meanwhile, gamedevs nod along to the real talk: juggling time across frames turns code into a Rube Goldberg machine, and scripts that read like a story — “jump, step, rotate” — feel like magic. Bonus meme: folks humming “Let’s do the Time Warp again!” at every next-frame wait and bookmarking the Unity docs like it’s a cheat code.
Key Points
- •C++ coroutines have existed for about six years but are rarely encountered in production due to integration complexity and limited practical examples.
- •Unity primarily uses C# for gameplay code and leverages coroutines to manage short-lived, time-based effects.
- •Unity’s coroutine pattern uses 'yield return null' to effectively wait for the next frame, a legacy of early C# support lacking async/await.
- •A complex, staged effect is expressed succinctly with coroutines, advancing one step per frame.
- •Implementing the same logic without coroutines in C++ becomes an explicit, cumbersome state machine, illustrating coroutines’ value for time-spanning gameplay logic.