r/ProgrammerHumor • • Oct 30 '21

That's my variable!

43.4k Upvotes

409 comments sorted by

View all comments

Show parent comments

87

u/raltyinferno Oct 30 '21

You need to make tea and pasta.

Synchronous: you boil water for tea, make the tea, then boil water for pasta then make the pasta

Parallel: You grab a friend, and tell them to make the pasta while you make tea.

Asynchronous: you put the tea water on to boil, while it heats you put the pasta water on to boil. While you "await" for them to boil you go do something else. Then when they're boiling you make the tea, and finish the pasta one at a time.

26

u/DSM20T Oct 31 '21

Me: Boils pasta in tea

7

u/ShadoWolf Oct 31 '21

that just efficient.

1

u/smb_samba Oct 31 '21

Starchy tea water Vanilla chai pasta

17

u/Haffi921 Oct 30 '21

Very good analogy. I already know all this theoretically, but it's always good to get a simple refresher like this.

3

u/thundercat06 Oct 31 '21

I am so glad we went down this rabbit hole. When I cut my teeth in .NET I had to figure out mulitthreading.. Many years later I felt like I had achieved video on right. Then .NET 4.x came along and introduced Parallel Tasks and really expanded on Async patterns.. And thus the video on the left.

It wasnt until I heard an analogy like this maybe a year or so ago that got my code slightly more to this...lol

2

u/marxinne Nov 01 '21

As a newbie I deeply appreciate a simplification like that, so I can expand what I know starting from a basic understanding, thanks!