DEV Community

Roger Stach
Roger Stach

Posted on

Explain async like I'm five

Top comments (4)

Collapse
 
itsjzt profile image
Saurabh Sharma • Edited

for knowing Async you need to know one problem that exists while using computers or may I say programming computers.

The Processors are the fastest thing in the whole computer next to them are Cache and then RAM and then secondary storage. Tasks using secondary storage, calling to another server over the internet, doing something in the database are slow and they are collectively called I/O tasks.

I/O tasks are slow because calling to the server requires a lot of waiting time, storage devices are slow too. BUT JavaScript waits for nobody. That's why ASync Await was made. It's basically like saying "hey JavaScript this function will do some I/O tasks, so wait for the tasks that say you await.

If you understood that then great, see this video for digging more deep youtube.com/watch?v=9YkUCxvaLEk

Huh! my first ELI5 explanation. •ᴗ•

Collapse
 
rhnonose profile image
Rodrigo Nonose

Sync is: saying "Good morning" and waiting for the person to reply.
Async is: writing a post-it saying "Good morning" and leaving on the person's desk.
You expect the response as a post-it in your desk as well.

Similar analogy for computing can be applied. When you want to call a method/function/procedure/endpoint or anything, you call it.
If the processing of that call is done in the same "concurrent unit" (aka process or thread) by the caller and the caller waits for the result to be finished, it's synchronous. Otherwise, it's asynchronous.

Collapse
 
saurabhgoyal profile image
Saurabh Goyal • Edited

Check this post of mine - scheduling-a-task-for-dummies

Also feedback would be much appreciated.

Collapse
 
samdbeckham profile image
Sam Beckham

async holds water that usually comes from a4set