Storytelling Lessons from Programming: Callbacks Ain’t Just for JavaScript
Or how I learned to stop coding and start telling stories.
If you know me at all personally, this is probably the least surprising blog I’ve ever written. I literally made my own major called “Writing in the Computer Sciences” when I was in college. I’ve always believed there is a lot of overlap in these two areas, even though almost everyone I talk to is confused about how and why they are similar. To me, they both just make sense: one is attempting to communicate with something that is a slave to its own programming, nothing more than a series of instructions blinded followed to an inevitable end.
And the other one is programming.
Let’s talk about callbacks. Callbacks are something that you will notice all the time if you analyze or look at existing media. You may even have an idea in your head about what a callback is in stories, but in programming they are a little bit different and, as a result, the way I think of callbacks in stories is a little different.
To explain callback functions in programming, I have to take a step back and explain what a function is. A function is essentially just a list of instructions contained in a nice little package with a name, so that you don’t have to copy and paste those instructions around to a bunch of different places in your code. Think of a function like a recipe: it’s a list of steps in order to make some delicious pie. Functions take inputs called “parameters”, which change the way that a function works. Think of a parameter as the particular type of pie you are making. For example, your instructions are different if you’re making a meat pie vs a pumpkin, but the crust may be the same; the only thing you’re changing is the filling, and the parameters tell you which filling to make.
A callback is a function that is passed as a parameter to another function. The parameter isn’t the result of the function, but the function itself to be used as a reference.
In our pie example, this might be a particular recipe used to make the filling of the pie. So, instead of having all of the instructions for every type of pie inside the recipe, you can say, “Go look at this recipe to make the filling and then come back here to put the filling in the pie and finish the rest.”1 This could be really useful if your delegating making the pie filling to your niece and nephew, while you continue to make the crust.
Now, if you’re really following me, you might ask why you’d want to do that? Why not just make the filling first, and then make the pie? What if your niece or nephew is a terrible cook and can’t really make a very good filling or follow instructions very well?
There are two reasons.
One: sometimes these instructions can be asynchronous, meaning that you can execute on both sets of instructions at the same time. For example, you might need to par-bake the pie crust first before you can put the filling in. So you might make the crust, put it in the oven to par-bake, and then make the filling while the crust is par-baking. You wouldn’t want to make the filling first before you par-bake the crust, because then you aren’t doing anything while it’s par-baking, and you always want to be doing something. You’re an efficient baker!
Two: so that you can change the context of the recipe you’re making. For example, a pumpkin filling on its own can go into a pie. But it could also go into a cake or a pastry or waffles. It doesn’t have to go into a pie. It’s just one context in which this pumpkin filling could work. And the recipe for the filling is the same, regardless of the context where you execute it.2
Okay, did you follow that? Mostly?
Good, me neither. Now, how the hell can this help you in storytelling?
A callback in storytelling (or, at least, the way I think of them) is a repeated item or motif or scene that helps to indicate the change in context as the arc of your story completes. One of the best descriptions I’ve heard of writing a book is “Write it all the way through to the end and then make it seem like you knew what you were doing from the very beginning.” And this concept of callbacks showing the way a character changed through context is one of the most useful ways of making the reader seem like you knew what you were doing and making a story feel satisfying.
This is getting really nitty-gritty and technical, so let’s do what I always want to do when trying to explain something like this: take a look at an example.
Let’s say you are writing one of the more common stories in the world, a Bildungsroman, or a coming-of-age story. In one of the earlier scenes, an older, mentor character has a conversation with your main character and dispenses some wise advice. It doesn’t really matter what the conversation is about, just as long as it seems meaningful to the character at the time, and it probably shouldn’t be longer than a couple of lines. At the end of the arc of your story, let’s assume your character has grown and changed and become wiser (because that’s what’s supposed to open in a story like this) and now they have a younger character that they’re mentoring, just like they were being mentored at the beginning.
Now, they repeat that same scene that happened at the beginning of the story with your older main character taking on the lines of the wise-old mentor and the character they’re mentoring repeating the main character’s lines from the beginning of the story.
This is a powerful building block, allowing you to show where the character started and how much they’ve changed to get where they are. It shows the cyclical nature of the world, a sort of symmetry.
There is something that George Lucas said in one of the behind the scenes videos from Star Wars Episode I: the Phantom Menace, that has kind of become a meme within certain quarters of the Star Wars community: “You see, it’s like poetry,” he said. “It rhymes.”
No doubt about it the way he said that was funny, but really he was talking about callbacks. He was talking about the way that you can have certain things repeated in different contexts to reflect the idea of the more things change, the more things stay the same.
Let’s look at another example: John Mulaney’s standup special from two years ago Baby J. I could spend a whole blog3 talking about what there is to learn about storytelling from standup, but for today let’s just focus on this particular special. The special focuses on John Mulaney’s experience with cocaine addiction and rehab, and begins with him relating the intervention his friends held for him back in December of 2020. He is then taken via private car from the intervention to a rehab, but stops on the way to do some cocaine on a Koala baby changing table4.
The rest of the special happens, and one of the last jokes of the night, is about him going to a museum with his new child and having to use one of those baby changing stations. Now, does this effect the story in anyway? Does the use of the baby changing station to do cocaine “foreshadow” Mulaney using a baby changing station for its intended purpose later on? No, probably not, but it adds a comparison of those different moments in his life, allowing you to see how much his life has changed from before and after rehab.
This callback is so important that when John Mulaney was interviewed at the 92nd Street Y about this special, he talked about the effect forgetting this particular detail has on the audience's reaction to the later half of the special. If you watch the special, you’ll hear the detail, but you won’t recognize that it is important until it comes up again later.
Callbacks are difficult to work with (notoriously so in programming), but they are incredibly powerful. They can do so much to portray so little in a story, and provide a narrative gut-punch that is really what you need to get your story to land. They can’t do everything for you, but if you’re trying to figure out how to make something work, go back to the beginning. What can change? What can stay the same, but the main character can see differently? And after you’re done figuring it out how to make that work, have a slice of pie.
After all, you’ve earned it.
Programming nerds, if this isn’t quite the same definition, humor me. I’m trying to break things down for the English majors over here
My fiancee, who is a much better baker than me, pointed out that this recipe would probably change a little on context, but that doesn’t work for this metaphor, so I’m leaving it as is. Bakers be damned.
And at some point, I probably will!
I swear, all of this is relevant.
I’ve written a lot of computer code in my career so I could follow your explanation, though not sure I think about how you apply this to writing the same way. A bit of a long way around though we all get to write in our own ways. Thanks for an entertaining lesson.