Subtitles section Play video
So that's my Twitter handle.
Add Matic Alina, please ask me questions.
Whatever.
I replied most of the time.
So I'm here today to talk about the No Dario, you might ask why Note?
Well, I am part of the notary s technical steering committee.
So whatever a lot of things.
No J yes.
If you have questions about North courting me, I'm so Ah, I'm also ah, principal accurate in here for me on a professional service company distributed around the globe, but busy in Ireland.
Whatever.
If you need us, we're there.
Check it out.
Check it out.
Also, another little bit of intro There is these lights.
If you have a laptop, there are some interactive visualizations.
So if you have a laptop out and you want to play with them these of these lights you can take a picture, whatever.
Whatever you want.
Um, so let's get started.
Um, when everybody starts with note, they start with a very simple question out of the bag.
A synchronous activity.
You know, you have a socket coming in on http request coming in and you want to react Thio those activity And you know what?
Everybody does well I can use the inspector protocol.
They expect a workroom inspector.
And they just left.
Yeah, more or less.
But what if we have 10?
Uncover?
Request our 100.
How can I?
The the bug on application running in production where I have a lot off concurrency in place.
Another I came from the Java word.
Whatever.
I've done this and this and I've said it.
You could stop a thread single tried in just the bag back.
You can't do that.
What?
So most of the stuff is because no Js is based on a concept called the evidence and you're probably are familiar with the No David Loop.
Um, okay, How many if you think they are from either with a no Devon loop.
Okay.
How many of you have seen this less people?
This is this the secret source?
Okay, that's the most Eden piece off node lower that you can find.
Took six months to write that guide.
Please read it.
If you want to know more about how note works and this is our no Devon loop works, probably not really easy to understand.
So let's reached one more easy to, uh, understand version because probably a little bit more clear to everybody.
So when JavaScript is exact executes, the only thing that note application does when it leads to a Iot, it talk to the colonel.
I think your barrier or a threat and says When this event happens, when this condition happens, please call back.
Call a function.
When this finishes that the only thing that that no does on dhe it specified a passing as a musket function.
And, you know, some event happens like you are receiving some data from a socket and that it calls back, and then he wants to call that function.
How does that happen?
That is E.
Let's see.
Whoa, there is an event you here and the event you means that all the functions are processed one at a time on.
So just to repeat at the dusky primetime specify effort at the function as a listener to some io event, and then the your event happens and the function is called.
But you know that is one cholera.
To all of this, we have only one function executing again given time.
And this is one of the key tenants off Annie Know Js and you know, Js function now you might ask why all of this matter why I'm doing a singles activity wouldn't make things simpler.
Yes, and now it makes things simpler to code.
However, that is one key piece that is a little bit obscure, which knowing which code is running relative to one another.
Um, also what about next week?
Promises and set immediate.
Now which one would learn first?
You scheduled a promise if you run a promise if you do next IQ, or if you do set immediate, you know I'm no throwing set time out Vero in there because that's even trickier.
So next week, every police executed before promises are resolved and before any other your events promises are.
If you do new promise, the function is executed.
Sink a lovely, but then resolve our synchronously and before any other io events set immediate.
Instead, exists eyes the full event loop that we told you that we've told you, you know, and have not thrown in city meets a time a Vera because that's another rival complication.
So again, the artist piece off information.
That thing that when a newbie starts working with note, is to know when a chunk of code is executed relative to one another.
So going back to the question out to the bug multiple a synchronous activity.
How do we do this?
Because, you know, we have multiple things happening.
How do we have a bad bug on that is happening Only when I'm calling three different routes at the same time and the moon is aligning and Marcie's over there?
I don't know.
It's really gets complicated.
And her I don't understand what what is happening in here is very hard.
So it goes back to a problem that something that you're missing in basket, which is the concept off their synchronous context.
So let's look at a bad, very basic, http Server of written in Notre.
Yes.
And you can see that we do our http, create server and we're passing a function this function.
In fact, when we receive an http request from a browser, you have a new logical sequence context that is being created, which means, you know, this is your transaction.
This is your htp requests and response.
This is a logical concept that is living in there.
Okay.
All the things that the sun from this one will be, you know, linked.
One wished another, mainly because they're part off the same closure.
You see, it's a closure created here, so they're part of the same closure.
And then when I create another closure, you know it's in here.
Okay, on dhe, the context is being the response is being propagated just by using that, um so it's really powerful, right?
However, there is no concept off our signals.
Contacts in the jobs keep language.
So you know it's something that is built in into our treasure works and how the event loop works.
But there is no way to control in any, uh, reflection oriented way this type of things.
So it's completely a logical counts construct, but is not a language, not the language feature.
There is some work in making these a reality where there's actually a concept in the language back and some of the war.
You can find some of the work done by the diagnostics working group in know Js.
Check it out and it goes a little bit into the deep depths of this, and it's really, really interesting to read.
Um, then well, if there's no concept off seniors context.
How can we track I?
You events?
So how can we know when things happen?
You know, there's a thing called Ace and cooks.
You've probably heard about a scene cooks in the past on dhe.
It's one of those, you know, new features off.
No Js that do that can do great things.
Also, you know, they're somewhat hard to use.
This is an example off Using them is actually really, really code.
Uh, can you understand what he does?
Wow, it's complex, and it also generates a lot of data, and I'm not going to explain it because it's a really that conversation.
So myself.
In my team, we have worked for six months trying to make sense about all this stuff and out to provide a way to reason about the synchronised context and their singles activity.
No, Joe.
Yes.
So you know.
And when you have this type of question, the best way to attack this problems, you know I am a software engineer, okay?
By trade, whatever s o.
You know, you go well.
You ask a designer Sorry, we can't do this.
So I ask.
We ask.
I ask a designer.
Can you please sit down?
We don't need a bit of a design.
Worship whatever to figure this out.
Turns out that they they answer to the question on out to visualize a synchronous activity is at bubbles.
So bubbles.
Yeah, that's it.
So let's make an example.
We have we have a nice, very tiny piece off asses off code here.
Okay?
Is the same server that we were talking about before you?
So we go to a lot of lights, so Hey, so we go to our So we're here and we have that code.
Now we can use this tool called Bubble Profit and this part of a sweet girl cleaning.
You might check it out late.
This is Quintin linked and out.
A cannon is a tool to relate some load.
So we're putting in 1000 requests.
Just spice things up to know what things behaving, production.
And basically, you're under your code lot.
Probably.
I've typed.
Yeah, we're on our code now.
You can see that out of Cantonese, cleaning things up a little bit and running a bit.
A bit of those requests.
Um, and it's basically now generating your visualization takes some time.
You know, this machine is not powerful little and these is a battle productive.
Now I'm zooming in on Dhe eso What we can see on the right side is the number off a synchronous operation being done off by this system.
And you can see that is doing you know, we have Ah, 12,000 synchronous resource being created by running after 1000 requesting know Js Does this help anybody?
Maybe yes, maybe.
No.
The important part.
Our boy for the down, we can start from the root.
So when the route this is the route note and represent the starting point of your application?
Yeah.
Then we can go deep and, you know, see the first part and the first part.
In fact, it's online.
20 off our application.
Basic Dodger.
Yes, whatever it is.
And it's out called to serve a dot Listen, our server is starting to listen stuff.
Still, this is not helping me in the eye knowing what is happening in my nose application.
So the next part, it's this big block here, which is a bunch off on network activity, which is you can see it in green and this bunch of network activity.
It's that some bunch off anti frames, these air note core stuff, But then we have a bunch of another nautical stuff which come from how we receive a TCP connection in no jail.
Yes itself.