It means “happening at the same time.”
Like the end state of these metronomes. Synchronous.
Pretty simple, right?
The word “sychronized” means pretty much the same thing. Synchronized, sychronous, in sync… They all mean the same thing. In fact, the prefix “sync” means “together.” So pretty cleary, it must mean the same thing in development, right?
I’m afraid not.
Now. In many tutorials about asynchronicity, this fact tends to get swept under the rug. My best guess as to the reason for this is that we’re trying to convince each other that we’re using that word for a good reason besides the fact that, at some point, some dev somewhere very clearly fucked things up but now it’s too late to change things and this is just the word we all have to use.
But in my opinion it’s important to talk about, and to understand, for a couple of reasons. One, it’s necessary for understanding async programming, and two, it’s a good reminder to think hard about how you name things, because you could be starting a convention that ripples outward for decades to come.
Outside of web development, you would expect “asynchronous” to mean “not at the same time.” And this is essentially what it does mean. When people talk about “asynchronous communication,” they’re talking about things like email - communication media where people don’t need to be using it at the same time for it to work. A phone call, conversely, would be a synchronous form of communication.
Now remember - in web development, synchronous mean “sequential.” So in development, asynchronous means “not sequential.”
Let’s imagine that we are writing some code to perform the following tasks:
1. Create an account for the user 2. Send a confirmation email to the user 3. Thank the user for signing up
Some code that is operating sychronously would basically just do this:
1. Create account 2. Send email 3. Thank user
However, let’s say that the email takes a while to send, and that we don’t want to wait for it to finish before we display the thank you message. We can do this:
1. Create an account for the use 2. Start the process of send the email, but don't wait for the task to finish. Just let it run in the background 3. Thank the user for signing up 4. Email-sending process finishes
This is a super common use case for asynchronous activity.
One thing you might notice about the last example is that at a certain point in the program, steps two and three are running at the same time. So somewhat perversely, our asynchronous code is running in a way that is literally the opposite of the non-development definition of asychronous, which as we can recall, was along the lines of “not happening at the same time.”
To some, it may seem a bit nitpicky to have an entire post teasing apart the differences between the various definitions of synchronicity. But to me, these kind of inconsisencies can be extremely destructive, especially if left unaddressed. According to Bob Martin, the number of programmers doubles about every five years. And almost all of them will, at some point, have to figure out asynchronicity. “Asynchronous” is a poorly named variable in the codebase that is our industry. It’s a giant piece of technical debt, a convoluted N + 1 query in the education of junior developers. I propose replacing the terms “synchronous” and “asynchronous” with “sequential” and “asequential.”
Now let’s enjoy some lovely synchronized swimming. I personally prefer the duets to the team event.