Call stacks in everyday life
Call stacks are a thing in programming, but they're also a thing in everyday life. Realizing this seems, at best somewhat useful, and at worst interesting to think about.
In the video, Louis CK tells the audience about how his wife is bad at telling stories.
Speaking of Louis CK, have I ever told you how much I love stand up comedy? It's really one of my favorite things in the world. When done well. Going to the Comedy Cellar in NYC was one of the best experiences of my life.
Speaking of NYC, I might end up moving there for a job. That'd be interesting. Coming back to the town where I grew up. Well, I grew up on Long Island technically.
Speaking of white lies, I'm kind of a fan of them. They can be problematic, but they also have their uses. For instance, the distinction between me having been raised on Long Island versus NYC wasn't relevant to you, and pretending that I grew up in NYC made the sentence flow better, so why bring it up in the first place?
Was that last use of the word "it" clear? Maybe I should be more specific.
Wait, what were we talking about again?
I have a small problem. In conversations like these, I usually want to "hold on to" the structure.
- You're talking to me about this Louis CK video. Ok.
- Now you're going on a tangent about stand up comedy. Cool. We'll finish that and then come back to the video.
- Oh, now you're talking to me about NYC? Hm, ok. Let's discuss that, then return to stand up comedy, then return to the video.
- Wait now you're talking about white lies? This is getting hard to keep track of.
- The word "it"? Really?
I don't know why I do this. I think the natural thing is to just "let the conversation flow", but I use up mental resources holding the structure in my head. I've been known to actually answer questions like "How did we end up talking about X?". "Well, we were talking about A, which lead to B, which lead to C..."
Anyway, we're not here to talk about my problems. We're here to talk about call stacks.
The conversation can be represented like this:
it white lies nyc standup video
First we were talking about
video. Then we started talking about
standup, so we put
standup on top of
white lies. Then
Imagine a stack of plates. You can't just take out the bottom plate and use it (unless you're really good at Jenga). Here, if we want to return to the conversation about
video, we have to finish talking about
it, then finish
white lies, then
nyc, and then
standup. Then, and only then, can you return to your conversation about
video. If you skip a step, the gods of recursion will find you.
Tasks in general
It's not only conversations where this sort of thing happens. It's with daily activities too.
For example, before writing this article I was getting my dog ready for a walk.
But then I realized that the kitchen needed to be cleaned, so I started doing that.
Then I got inspired to write this article, so I started doing that.
Then I got a text from my brother.
I just responded to my brother.
Now I'm going to finish up the article.
After that I'll finish cleaning the kitchen.
After that I'll finally go and walk my dog.
Again, if you don't proceed through the tasks in precisely this order, the gods of recursion will have your neck.
Wikipedia rabbit hole
Surfing the web is particularly prone to big call stacks.
Maybe I should talk about what this looks like in programming. I'll try to make it accessible for those who aren't programmers.
Imagine that we want to get the user with the id of 42. To do that, we need to know which database to look at. To know that, we need to know what time of day it is.
get_time_of_day decide_which_database 42 get_user 42
Once we know what time of day it is, we're back to
decide_which_database 42 get_user 42
decide_which_database tells us that since it's the morning and we're looking for a user with the id of 42, we should look in database #7.
Now that we know what database to look in, we can grab the user and finish the execution.
More generally, the idea is that the situation looks like this:
I want to do A, but to do A I have to first do B, and to do B I need to do C, but to do C I need to do D. So I do D. Now that I finished D, I can do C. Now that I finished C, I can do B. Now that I finished B, I can, finally, do A.
Hopefully this way of thinking will be a useful mental model for you.
If you have any thoughts, I'd love to discuss them over email: email@example.com.
- 2 toasts