At 20:26, when he shows stdouts, it s actually non-deterministic that setTimeout's callback fires before immediate. One time it can, and other time it can be vice versa, since it depends on OS load, and characteristics. setTimeout with zero is actually will be cast to 4ms under the hood, and event loop can get to the first setImmediate phase faster. Otherwise, it's great presentation nevertheless!!!
it would be deterministic here because calculation of Fibonacci will take some time so by that time setTimeout callback will be added to the timer queue and will execute before check queue callback
15:04 I think the tick on the diagram is wrong. There should only be one tick after the event loop takes a full trip. Ref: nodejs.dev/learn/understanding-process-nexttick
@@fadelibrahim7663 But when we create a promise, the promise is asynchronous. so my code is asynchronous let myPromise = new Promise(function(resolve, reject) { resolve("true"); }); await myPromise
@@movie961 look I agree what he said causes confusion. And yea a promise is async, the timers are async, network request are async, file system request they are async if you used the async ones, process.nexttick is async, streams are async, (those are the code that's get scheduled/pushed to the process.nextick/microtask/timers/poll/check queues) I think those are the phases of the event loop that he covered there is other but we don't use them, so what he means is everything you write that's not scheduled added to the above queues it is "your code" he is talking about, it is the sync code that gets executed before anything else of the async code.
This was really great. It is so underrated
Thanks DK ,This is what i was waiting for. All the best and thanks for contribution.🙏
At 20:26, when he shows stdouts, it s actually non-deterministic that setTimeout's callback fires before immediate. One time it can, and other time it can be vice versa, since it depends on OS load, and characteristics. setTimeout with zero is actually will be cast to 4ms under the hood, and event loop can get to the first setImmediate phase faster. Otherwise, it's great presentation nevertheless!!!
it would be deterministic here because calculation of Fibonacci will take some time so by that time setTimeout callback will be added to the timer queue and will execute before check queue callback
Fantastic talk. Thank you.
15:04 I think the tick on the diagram is wrong. There should only be one tick after the event loop takes a full trip. Ref: nodejs.dev/learn/understanding-process-nexttick
Seems what he really mean is the process.nextTick callback.
@@sten6160 what do you mean? it looks like he missed to specify process.nextTick section in eventloop diagram right?
@@amlivinginhell process.nexttick add callback to microtask queue, which is checked in between each phase, that is what it means here in the diagram
Awesome explanation of event loop with good diagrams.
what a genius !! Thanks.
4:53 my question is what is the meaning "everything in node js is asynchronous except your code
the code thats not async, for example a normal function, function example(a, b){return a+b}
@@fadelibrahim7663 But when we create a promise, the promise is asynchronous. so my code is asynchronous
let myPromise = new Promise(function(resolve, reject) {
resolve("true");
});
await myPromise
@@movie961 look I agree what he said causes confusion. And yea a promise is async, the timers are async, network request are async, file system request they are async if you used the async ones, process.nexttick is async, streams are async, (those are the code that's get scheduled/pushed to the process.nextick/microtask/timers/poll/check queues) I think those are the phases of the event loop that he covered there is other but we don't use them, so what he means is everything you write that's not scheduled added to the above queues it is "your code" he is talking about, it is the sync code that gets executed before anything else of the async code.
nice talk! 👏
Actual video starts at 11:50
Woops, wrong Daniel khan
what wrong?
@@movie961 nothing, I just meant this one ua-cam.com/video/6VoMrvOzYCQ/v-deo.html
19:25 fibonacci(20) == 6765 :) not 10946 (fibonacci(21) == 10946)