Async explained with Human Analogy.

Jacky Lin
2 min readSep 1, 2020

Define Asynchronous

Here is the MDN definition, “asynchronous refers to two or more objects or events not existing or happening at the same time (or multiple related things happening without waiting for the previous one to complete). In computing, the word “asynchronous” is used in two major contexts.”

A much simpler definition would be:

  • Multiple threads executing code at the same time
  • More than one bit of code running at the same time

Obviously that is not the best explanation, so I will be giving you an example that would make it easier to understand.

Asynchronous Example

Imagine you’re making chicken soup, that contains the ingredients of chicken broth, Costco rotisserie chicken, celery and carrots. The way to make the soup is:

  1. Dice the carrots
  2. Dice the celery
  3. Cut the Chicken
  4. Add chicken broth into the pot, turn the stove on and wait for it to boil.
  5. Add the chicken when broth is boiled for 15 mins
  6. Add the carrots and let cook for 15mins.
  7. Add celery into the pot and let it cook for 10mins.

Whilst you have made a very delicious chicken soup, it was not the most time-efficient way to cook. If you look at the steps, there is a lot you could’ve done to save time.

  1. Steps 4,5,6,7 is nothing more that spectating the pot.
  2. Only steps 1 and 2 require you do chef it up

A more logical way of making chicken soup would be the following:

  1. Boil the chicken broth on high heat.
  2. Whilst the Broth is boiling, start chopping the carrots and celery.
  3. When you finish chopping up the carrots and celery, the broth should be done boiling
  4. Whilst the broth is boiling add the chicken, celery and carrots in for 30minutes.

I am no Gordon Ramsay with this recipe but this was the best way to explain async. They are still the same steps but split into more faster and efficient way. Which transcends in the world of programming. Client never wants to sit around purely waiting for something to happen. In conclusion Aysnc is having to be actively doing something and not just waiting around, which gives the meaning of Asynchronous Programming.

Reference: https://medium.com/javascript-in-plain-english/javascript-async-await-and-promises-explained-like-youre-five-years-old-61733751e9a5

--

--