Synchronous v/s Asynchronous

3 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
This is a free item
$0.00
د.إ0.00
Kz0.00
ARS$0.00
A$0.00
৳0.00
Лв0.00
Bs0.00
B$0.00
P0.00
CA$0.00
CHF 0.00
CLP$0.00
CN¥0.00
COP$0.00
₡0.00
Kč0.00
DKK kr0.00
RD$0.00
DA0.00
E£0.00
ብር0.00
€0.00
FJ$0.00
£0.00
Q0.00
GY$0.00
HK$0.00
L0.00
Ft0.00
₪0.00
₹0.00
ISK kr0.00
¥0.00
KSh0.00
₩0.00
DH0.00
L0.00
ден0.00
MOP$0.00
MX$0.00
RM0.00
N$0.00
₦0.00
C$0.00
NOK kr0.00
रु0.00
NZ$0.00
S/0.00
K0.00
₱0.00
₨0.00
zł0.00
₲0.00
L0.00
QR0.00
SAR0.00
SEK kr0.00
S$0.00
฿0.00
₺0.00
$U0.00
R0.00
ZK0.00
Already have an account? Log In

Transcript

Hi, everyone. In the last videos we talked about concurrency, parallelism and concurrency versus parallelism. In this video, we're going to be talking about synchronous and asynchronous coding patterns. So when you write a C, c++ Python code in a functional programming language kind of a way, what happens? So in our analogy, these are functions, function one function to function three and function four, right, and then the size of the function or the size of the rectangular block, says that how much time this function takes versus how much time this function takes. So let's say this function is bigger than this function, which means that function one takes more time to finish and function two.

So if you say function one, then function to function three, then function four. In a standard synchronous programming paradigm function one is going to execute and then function 234 are going to wait for function one to complete. When it completes, function two is going to run, three and four are going to wait. Then function three is going to run Food is going to wait. And then finally four is going to run. So, if you take a look at the timing, then it takes a lot of time for this execution to actually complete.

Now taking a look at asynchronous programming paradigm, take a look at this. So, if rather rather, executing these functions in one in the order of 123, and four, we execute these at the same time in an asynchronous fashion, look what happens. So, function 123 and four are running simultaneously in a concurrent kind of a way, right? So it might be like this, it might be like this. Right? So function one runs function two and three, are executed at the same time.

They don't need to worry about if function one has been is being called or has returned something or not. They're called irrespective with function one, function four is also being called at the same time asynchronously. So all of these four options are running asynchronously, they don't need to wait for these other functions and they have no idea about these other functions. And to, to have them get the idea about the other functions is what is known as inter process communication. So let's say I have this function to which needs something from function one, and as well as it needs something from function four. So, it can take those things in in a process, which is called IPC or inter process communication.

And then if you take a look at this, the timing is nowhere near close to the synchronism packet. So asynchronous patterns are really good when you're looking at web development or when you're looking at bulk tasks or tasks which take a lot of time so that you don't have to wait for those tasks to happen. You can do this in a fire and forget manner. So fire means calling a function and then forgetting means that okay, you call it a function, you don't need to worry about the completion of the phone. You can immediately start calling other functions. And you don't have to worry about them being completed as well.

But as soon as all of these functions are completed, you can run another function which would say that okay, return zero or something like that. done right. So this is a synchronous pattern versus a synchronous design pattern. So, in the next video we are going to be delving into go and how to implement and how to do go routines and asynchronous programming paradigm in golang in a practical kind of way, so stay tuned and see you guys in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.