YouSNR
♥ Keep these topped up:
All signal, no noise

Jonathan Blow on coroutines and concurrency

Jonathan Blow highlights · Mar 30, 2026
Watch on YouTube ↗ · · 21 words corrected

In this video

Click any line to see what was on screen · double-click to watch from there

Chapter 1: The problem with coroutines

0:00Wondering what I think about stackful stackless. I don't give a shit about coroutines. I don't I don't know why 0:07people like them. All HTTP calls and database calls block the thread. Yeah, 0:13we just have a thread do that. I don't like it doesn't take much to start a 0:20thread and give it a function and say do this function, right? That's the thing. 0:26And so the reason I don't care much about coroutines is because they take all this extra infrastructure 0:35to give you like a small amount of syntactic sugar on top of that. Now this becomes a little bit different if you have a different thesis

Chapter 2: Threading vs coroutines

0:43about the language like so for example go has a thesis that it makes sense to 0:49have a 57 quintillion coroutines most of which are asleep right but I don't 0:57think that's true that doesn't make much sense to me at all so like I why can't 1:05you just have a function and say job system please do this you know how do 1:14you handle recursive dependencies I mean in this language they're just like automatically handled I don't I 1:21don't know what the problem is you could do async to async I mean I don't think so here's the thing you

Chapter 3: Asynchronous data handling

1:30never really want to do anything totally async when you're reading a web page anyway right it's like because if you're going to somewhere to request request 1:39some data, it's cuz you want to use the data in a second, right? It's just you might want to do three things at the same time because the web is all messed 1:47up that way. So yeah, you just do the three things at the same time and then you wait until they're all done and then 1:55you go, right? Like that's fine. That's that's a multi-threaded program thing. I 2:02just I don't really understand what coroutines really gives you apart from oh I'm in a super high-level 2:11programming language and so I can pretend I that I have this certain infrastructure right but this isn't a super high-level programming language in 2:19that way I mean it's very high level for a systems language but it is a systems language so I mean coroutines and the

Chapter 4: The trap of easy abstractions

2:27the other reason why I say that I don't think much of them is just They're like a lot of things in 2:34programming languages and frameworks and abstractions and all this stuff, right? 2:39There's this very very common pattern and the pattern is this thing looks tidy 2:47and convenient and neat for small easy problems and then doesn't 2:55help you much for difficult gnarly problems. That's like 98% 3:02of language features and abstractions and all that, especially in the past 20 years. And the problem is things that 3:11are easy are already easy. Why do you want to put why do you want to spend the complexity budget of your system on making things that are easy 20% easier? 3:23I mean, maybe maybe if everything you do is easy, then it makes sense to accelerate that by 20%. But that's usually not how it is. It's usually you 3:31blast through some easy stuff and then you hit one of the hard things and the hard thing is pretty hard. And like every all the design that I do is to 3:40help with hard things because that's the limiting factor on what we're able to accomplish is how many hard things are 3:47we able to do. And coroutines is one of these things that helps you with easy things. And I just I don't care about that.

Chapter 5: Performance and parallelism

3:54The problem is you block the thread holding the connection. What? No. 4:02What? No. I mean, unless you want to. 4:05No, you don't have to block the thread holding the connection. 4:09Implementation-wise, it's potentially more performant than a gazillion OS threads if you have a very, very large number of them. But nobody does. Nobody 4:19does. Like the example that I just gave you. I mean, again, there's there's two separate worlds, right? There's the web 4:26world where people think about concurrency, but concurrency, as I always say, is kind of a weasel word. In the game world, and in the other high 4:35performance application world, you care about parallelism. Parallelism is a stronger word than concurrency because 4:43it means you're actually doing things at the same time. Concurrency means that things may be overlap somewhat. It's a 4:51very weak word or you know the things maybe are unordered, 4:58right? Like what? Um so parallelism means oh we're actually using the

Chapter 6: Implementing task systems

5:05hardware that we have to get the task done more quickly. And if you want parallelism then the number of threads 5:13that you have should be related to the number of cores that you have. Okay? And there's no reason to create threads for 5:20everything like in the web example that I just said. You just write a fiveline function or whatever that gets the page 5:29and puts the result into a known place and you give that to the job system and that fires and and then it's done. You don't create a thread for that, right? 5:39You don't want to create a thread for that because you don't want tons of things running all the time, right? So one of the things he was trying to 5:47implement is to park jobs that are past a predetermined deadline. 5:53Wouldn't coroutines help since Windows dropped user mode scheduling blah blah blah. I don't know anything about user 6:00mode scheduling in Windows anyway. Um but wouldn't coroutines help there? I mean 6:08you could do that with coroutines but you can also do it without coroutines Like.

Chapter 7: Managing control flow

6:12like okay there's one very fundamental thing about programming in systems 6:19languages or many languages but you know like functional style languages give you primitives to deal with the following 6:26thing that I'm about to say uh when you're programming in system languages especially there's this thing where your control 6:35flow is interleaved with like the stack right there's this implicit data 6:42structure called the stack that has to be there for you to run, you know, and as you call functions and return from 6:50them, the stack bloops up and down and all that, right? And then the thing about what you're talking about about 6:57suspending some code naively in a systems language, you're like, "Oh, I don't know how to do this because I called all these functions and like I'm 7:06just on the stack somewhere and I don't know what to do." Right? But there are two basic ways to handle it. One is

Chapter 8: State management techniques

7:16on most systems languages. We actually don't provide a fundamental way of doing this, but you could implement it 7:22yourself. But you know in C back in the day, you would use setjmp and long jump and figure out the range of the 7:30stack and you would just copy the stack if you wanted to do that, which is maybe expensive back in the day, but these 7:38days is very cheap. because stacks are not that big. You could do that. Uh but but I wouldn't prefer to do it that way 7:46anyway. What I would do is just have so so the the way to become more powerful 7:54in situations like that is you just disentangle the state of the job that you're trying to do from the stack, right? And that 8:02just means you have a data structure that represents the task you're trying to do. you have a function that just 8:09iterates over the upcoming tasks and looks at them and makes progress on them, right? And once you centralize it 8:17in that function, um you uh you know, you can just yield if something is 8:24taking too long and whatever and go to the next one. That's kind of like writing your own scheduler, but it's tremendously tremendously tremendously 8:31simpler because it's only a simple set of well-defined things that you know everything about. Right? Now, of course, 8:40that by itself implies some constraints on the code. So, you can't call something that blocks indefinitely 8:48because you wouldn't be able to yield it, right? But like, you know, it's fine. Just don't do that.

Chapter 9: Cooperative scheduling

8:55Concurrency equals using same core. 8:57That's not true. No, concurrency is not even that well-defined. But two things on different cores are concurrent for sure. It's just concurrency. 9:09Like I said, it's just a weaker word than parallelism. 9:12I'm saying a timeout fires. No, not necessarily. The what I was outlining is more of a cooperative thing. um like 9:21you're talking about with coroutines, but coroutines implies a lot of things that are not really necessary if you 9:30just need to solve this problem within your own system. Like the thing is a co-outine abstraction is it's like built for customers of this 9:39language feature. And so it does a lot of things to handle a lot of things that people need to do in various cases that 9:47you don't necessarily need to
Timestamps open the video at that moment on YouTube.