> Markdown version of [/videos/690-coroutine-explained-yet-again-60-years-later](https://www.wearedevelopers.com/videos/690-coroutine-explained-yet-again-60-years-later). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Coroutine explained yet again 60 years later Why is a 60-year-old compiler concept driving modern concurrency? Discover how stackless coroutines transform messy callbacks into clean, highly scalable async flows. - **Speakers:** Mikhail Maslo - **Event:** World Congress 2023 - **Published:** September 27, 2023 - **Duration:** 30:43 - **URL:** https://www.wearedevelopers.com/videos/690-coroutine-explained-yet-again-60-years-later ## Summary Sixty years after Melvin Conway first introduced the concept for compiler optimization, coroutines remain widely relevant for managing complex execution flows. Unlike standard functions that execute and return, coroutines can suspend and resume their execution while preserving local state. Under the hood, modern compilers typically implement this behavior as a state machine—a pattern heavily utilized in languages like Kotlin and JavaScript to efficiently manage operations without blocking the main execution thread. The architecture of coroutines generally falls into distinct classifications: stackful versus stackless, and symmetric versus asymmetric. Stackless and asymmetric coroutines dominate modern language design because they consume minimal memory and return control predictably to their caller. While stackful coroutines allow yielding from nested functions, they require pre-allocating stack memory, making them slightly heavier. Symmetric coroutines function similarly to a system-wide `goto` by passing control directly to any other coroutine, though this pattern is rarely supported outside of specific languages like Ruby. At a system level, coroutines operate as lightweight user threads relying on cooperative multitasking, entirely invisible to the CPU or operating system scheduler. This model allows developers to linearize complex callback structures—often seen in heavily nested codebases—into clean, sequential instructions using the `async` and `await` paradigms. Because they consume significantly less memory than kernel threads and gracefully relinquish control during I/O delays, coroutines are an ideal primitive for managing highly concurrent, I/O-bound applications. **Keywords:** melvin conway, coroutine execution flow, state machine implementation, stackful vs stackless coroutines, symmetric vs asymmetric coroutines, cooperative multitasking, user threads, async await programming, callback abstraction, io-bound operations, concurrent task management, ruby symmetric coroutines, swift concurrency, memory-efficient multithreading ## Chapters 1. **Introduction to coroutines and their historical origins** (00:04) — Melvin Conway's initial work on co-compilers demonstrates how historical computing solutions established foundations for modern coroutines. 1. **Execution flow and suspending states in coroutines** (01:09) — Comparing regular functions to suspendable routines reveals how saving internal states enables advanced execution flows. 1. **Under the hood of coroutines with state machines** (03:29) — Translating complex coroutine execution into underlying compiler state machines provides a reliable mechanism for managing resumption. 1. **Differences between stackful and stackless coroutine classifications** (07:48) — Comparing stack reliance shows that stackful routines permit deep suspensions while stackless models minimize memory overhead. 1. **Symmetric versus asymmetric control transfers in coroutines** (11:49) — Analyzing yield behaviors illustrates how asymmetric models simplify caller relationships compared to arbitrary symmetric control transfers. 1. **Performance and memory tradeoffs among coroutine classifications** (16:53) — Evaluating varied coroutine structures guides developers in balancing execution speed with strict memory footprint constraints. 1. **Positioning coroutines within hardware and software thread hierarchies** (18:53) — Positioning routines against kernel resources clarifies how cooperative user-level threads avoid intensive operating system scheduling overhead. 1. **Implementing cooperative multitasking in modern programming languages** (24:54) — Applying asynchronous markers to heavy concurrency workloads replaces nested callback structures with linear readable code sequences. 1. **Audience questions on language support for async programming** (29:10) — Addressing language disparities emphasizes how coroutine support fundamentally accelerates modern asynchronous development workflows. ## Related Moments - [Simplifying asynchronous concurrency patterns safely with coroutines logic](https://www.wearedevelopers.com/videos/384-moving-from-java-to-kotlin) (from "Moving from Java to Kotlin") - [Compiler state machines and asynchronous concurrent task execution](https://www.wearedevelopers.com/videos/447-asynchronicity-and-multithreading-in-c) (from "Asynchronicity and multithreading in C#") - [Handling asynchronous operations with native Kotlin coroutines](https://www.wearedevelopers.com/videos/100250-building-a-cross-platform-ble-client-with-kotlin-multiplatform-and-kable) (from "Building a Cross-Platform BLE Client with Kotlin Multiplatform and Kable") - [Orchestrating concurrent routines with channels and goroutines](https://www.wearedevelopers.com/videos/191-concurrency-with-go) (from "Concurrency with Go") - [Adding strong type checking and generic programming concepts](https://www.wearedevelopers.com/videos/526-the-design-and-evolution-of-c) (from "The Design and Evolution of C++") - [Origins of Project Loom and lightweight threading semantics](https://www.wearedevelopers.com/videos/1973-beyond-loom-practical-patterns-for-virtual-threads-structured-concurrency-and-reactive-interop) (from "Beyond Loom: Practical Patterns for Virtual Threads, Structured Concurrency and Reactive Interop") ## Related Articles - [The Concept of Concurrency & Multithreading: What Are They And How They Function](https://www.wearedevelopers.com/magazine/89-the-concept-of-concurrency-multithreading-what-are-they-and-how-they-function) - [4 reasons why you should learn Rust in 2021 – and maybe even have fun doing it](https://www.wearedevelopers.com/magazine/35-4-reasons-why-you-should-learn-rust-in-2021-and-maybe-even-have-fun-doing-it) - [Using Java 17 latest features in real world projects](https://www.wearedevelopers.com/magazine/121-using-java-17-latest-features-in-real-world-projects) - [How to Avoid Over-Engineering](https://www.wearedevelopers.com/magazine/546-how-to-avoid-over-engineering) ## Related Jobs - [Senior Software Engineer](https://www.wearedevelopers.com/jobs/ext/15942-senior-software-engineer) at **GitHub** - [Software Engineer, Platform Engineering (L2)](https://www.wearedevelopers.com/jobs/ext/1956829-software-engineer-platform-engineering-l2) at **Twilio** - [Cloud Foundations Team](https://www.wearedevelopers.com/jobs/ext/1483289-cloud-foundations-team) at **GitHub** - [Senior Software Engineer, Fraud](https://www.wearedevelopers.com/jobs/ext/1280398-senior-software-engineer-fraud) at **Twilio** - [Principal Software Engineer, Database Infrastructure](https://www.wearedevelopers.com/jobs/ext/1465908-principal-software-engineer-database-infrastructure) at **GitHub** - [Senior Software Engineer, Client Apps Platform](https://www.wearedevelopers.com/jobs/ext/1773893-senior-software-engineer-client-apps-platform) at **GitHub**