This is the section that I'm waiting for, and that is synchronous versus asynchronous programming.
After we've gone through this section, it will help us to write fast, good performance code.
And above all, it will help us to develop real world applications like news app, text to speech application,
translation app and many more using external APIs.
So let's get started.
So in this particular video, we would differentiate differences between synchronous versus asynchronous
programming.
Let's see the differences between synchronous versus asynchronous programming.
Well, synchronous code is executed in a linear fashion.
That means one line at a time.
But for asynchronous programming or code, on the other hand, it execute code out of order, meaning
in power.
Which means that until this point, all the code that you have been reading are all synchronous code
because it execute one after the other.
And if you remember, on the high level of JavaScript, we talk about JavaScript as a single threaded
programming language.
That is why a code is being executed in order.
So if one code takes, let's say, 10 minutes to execute the other code below, it will wait until it
finished.
So this is what you call blocking or single threaded.
So when you say synchronize is also same as what?
Blocking code.
But asynchronous programming, on the other hand, don't do that.
But instead it can execute code in power or concurrently.
So why is it so?
And this is a time I will show you why we have this kind of features in JavaScript as asynchronous code.
So.
Here comes the question you may be asking that, well, if JavaScript is a single threaded and one thread
manages or the code is running, why is it that we can run code in power?
So as you move on you will see the differences.
So let's say in details, differences between these two programming style.
Well, we often shorthand asynchronous as async.
So when I say async, I mean asynchronous or right.
So for synchronous programming, it is what you call single threaded, meaning it uses one thread to
manage all our code execution, but for asynchronous code it is also called multithreaded, meaning
we have more than one thread to manage code execution.
So why is it so?
By default JavaScript is a single thread, so I'll prove to you as you move on.
And again, synchronous code is also called code blocking because if a function or code takes some time
to run and if otherwise below it cannot run, it means that it's blocking the other code from running.
But for asynchronous code it is non blocking code.
As you saw on the high level of JavaScript, we talk about JavaScript as non blocking.
Right.
And I showed you how I used that timeout to make this happen again.
We will revisit this technique again for synchronous code.
It handle one request at a time.
When you say requests, it simply means that getting or requesting a certain data from certain API into
your application.
In that case, you're going to hand it down one one at a time.
But for asynchronous, it handled multiple requests at a time.
And again, synchronous code gives poor user experience whilst asynchronous improve user experience.
This means how fast your application loads or run.
So with these two programming techniques, one can affect what user experience because it's slow and
the other one increase or improve user experience because it runs fast, because code doesn't block
other code from running again.
Let's see more in details.
Let's talk about synchronous programming.
All right.
So in this video, let's start with synchronous programming in more details.