Placeholder Image

字幕表 動画を再生する

  • everybody.

  • My name's Logan Huskins and I guess just a little bit about me before we get started.

  • I am a soft developer.

  • I work love travel Stop sign.

  • Been writing node at work pretty much exclusively for the last nearly three years.

  • Um, married.

  • My wife showed up.

  • That's pretty exciting.

  • Glad she gets to see me talk.

  • Um, I also helped run Oklahoma City in a Palm City mechanical keyboard user group.

  • So if you're interested, he would set me up, and we can I can show you where all that stuff that's pretty pretty, pretty dorky.

  • But I have, um So my plan with this talk is basically I'm gonna give some Hi, I'm really like high level concepts on some stuff.

  • And if it is complete and utter nonsense, as most of it will be initially I will circle back to pretty much every bullet point I have and kind of explain more in depth what those things are.

  • But if you have questions before that, if you have questions after that, just kind of wave at me, get my intention, I'm be happy to answer as many questions as I can.

  • So, um, we'll start off with what no Js is.

  • And this is pretty much right off the bat.

  • Gonna sound like nonsense.

  • And like I said, I'll circle back on everything.

  • No.

  • J S is a jobs for print.

  • Time built on top of Chrome's V engine is scalable.

  • Event driven has fast asynchronous io, which is input output.

  • It's generally used to make Web servers and developer tools, so first thing right off the bat is talking about V eight.

  • Um, if you haven't written before, you've probably not really heard much about V.

  • A Is the Java script engine inside of chrome that is used to execute execute the Java script you have on your website.

  • So if you ever have built a website with drama script, other using just plain JavaScript using angular react Js anything like that, Uh, when you run that application inside of a Web browser, the part that actually execute the drama script is V eight.

  • If you're using chrome, the cool thing about via is it's not actually tied to crow itself.

  • It can be embedded into any c++ application.

  • It's cross platform, so it runs on basically any operating system that you would expect a user have Windows, Mac OS, lynch, attributions, BSD, stuff like that.

  • The c++ application that it is used in that we're talking about is no.

  • So it is basically via outside of the browser and embedded into a separate run Time for Java script.

  • On top of that note provides a lot of libraries that aren't initially available n v eight and will run through a couple of those.

  • So I want to go through some quick examples to show exactly what that means.

  • Up until this point, what questions You guys have anything, All right.

  • First example.

  • We're just gonna do a simple hello world application.

  • Um, if you guys have ever programmed anything, I've sure you've seen this before, but this is just, um who on here doesn't have experience of jobs before I get started on this, they didn't have a lot of experiences.

  • Like any experience.

  • Okay, good.

  • So I won't explain what concert log is, but, um, we're gonna go ahead, just run that, and right there, it's printed out.

  • Hello, world.

  • So how we ran this application as we just call the note, execute a bowl and told it what script wanted to run, and then it'll run through that script, and without a browser, it will execute all of the drama.

  • This is a super exciting example, but it goes to show just the ability to run Java script without a Web browser.

  • So we'll go to a little bit more in depth example that shows some stuff that you couldn't necessarily doing chrome, and I'll go ahead and run through what this code does before I run it.

  • First thing it does is a prince Hello World for you guys again.

  • Then access is a global variable that's a part of no called process, which is something that's no specific and you don't you don't really do in the browser.

  • And, uh, it stores a lot of metadata about what application you're running and a lot of global thing going global things to it.

  • So if you have variables that you set outside of the application or something like that and we're accessing the arguments on it, so basically I want to call this application and pass the arguments, and then it's going to iterated through all those arguments and print out with the values of them all r and then a print were done when we're done.

  • So what it's done is iterated through all those arguments.

  • It actually took the executed all of note as the 1st 1 It took the script that we one and then all the things that I passed it from there on.

  • This shows that we can basically use things from our operating system that aren't they don't have to do with our browser so I can pass it anything I want to.

  • A lot of people will use us to do environment variables.

  • So if you have things like secrets that you don't want to actually storing your code passwords to service's database keys, stuff like that, they'll get past in and sort of a similar fashion, depending on how you set up your application.

  • What questions do you guys have about those before I go back to the flights?

  • Uh, well, so you you can pass 1/3 argument.

  • So for each return, the third argument, that is the actual right itself.

  • If you wanted to, you could check the length of that.

  • All right, but what for?

  • It does Is it liberates over there, Ray, and it stops at the last element of it, so you won't go over how many there are.

  • So it it takes all those arguments as an array and goes through each single one of those and performs this bit on each single one of those.

  • So you're not gonna go out of the bounds of that already or anything because of that?

  • And so, what you looking for?

  • Okay, you can write developer tools with no J s.

  • And there are lots of those will cover probably the biggest one, a little bit, a little bit called in p.

  • M.

  • But beyond those notice, primarily used to write Web servers, Web servers, for those of you that aren't familiar are basically how content is stored and served on the Internet.

  • It's where users, data, tweets, posts and all their information are stored.

  • So kind of an example of this is when you're say you're on Twitter and you tweet something when he when he hit tweet, it doesn't just stay on your computer.

  • It has to go somewhere that way when other people who are using Twitter and are following you on Twitter want to see your tweets, they can get them from somewhere.

  • So you send to what you hit tweet.

  • It sends it up to a Web server.

  • In this case, Twitter's Web servers and information is stored there for anybody later to come back and request.

  • So we're gonna kind of cover what something called the client server model is.

  • So I want to rent a couple examples of that, too.

  • Um, Web servers communicate with databases with file systems.

  • They communicate with other Web servers.

  • So if you have, if you ever heard of, like sequel server or my sequel or anything like that, they're running.

  • They're not running on your computer.

  • When you're running Web applications, they're running on a Web server somewhere.

  • Say, you have a, for instance, that you have a tweets that has a picture in it.

  • I don't know how exactly Twitter handles were images of how you could handle it is he could save it locally onto that Web server, which you can't, which means that anybody who makes a request to that Web server that Webster will then access the file system on the Web servants in the image down, so it has a centralized place for all of your tweets.

  • All the images you send up.

  • Basically, any information that's stored on Twitter is on their Web server.

  • It can.

  • Also, Web servers also communicate to other Web servers through networking protocols.

  • Like http, which is most of what we'll discuss today.

  • An example of that would be you send a tweet that has a link to a free code camp block post.

  • And when you see that sweet on Twitter, you'll see like usually like a little image that has to do with it.

  • The link A couple sentences about the link.

  • What happens is you said That's where it goes from your browser to a Web server to Twitter's Web servers.

  • Then Twitter's Web servers see there's only a minute and then make a network request to free code can slip servers so none of that happens on your computer.

  • It all happens on their server.

  • Web servers could be written a note written in Java, Ruby C.

  • Sharp and a host of other languages.

  • Today we're gonna be focusing on note what I just described to you guys, though it has a specific name, it's called the Client Server model, and it's a way to split responsibility between your Web server and the user's browser, where the Web server handles databases in her client communication and authentication.

  • The client handles you logic requests, info from other servers, stores, data in a database.

  • Um, for instance, with something like Facebook.

  • If you are on Facebook Messenger, you'd send a message to somebody on Facebook.

  • It wouldn't go directly to their phone.

  • It will go to Facebook servers, and then their phones would request that, or it will push it down to their phone, depending on how they set that up.

  • Do Does anybody have any questions about what Servers are kind of what the client server model is?

  • I can show you.

  • After this, I'm gonna show you some code of what a Web server like Looks like no questions.

  • All right, Before we get into that, actually, I'm gonna talk about why you would and wouldn't use No Jess.

  • And once again, this is gonna be nonsense until I kind of break it down and explain it step by step.

  • But no Js is good for asynchronous.

  • Not a second of applications that require non blocking input output.

  • And our event driven doesn't mean much.

  • I'll show you examples.

  • No, Jess is not good for CPU intensive tasks, so anything that requires a lot of math machine learning a I stuff like that note isn't very good at that because it doesn't have a way to handle it in a non blocking way.

  • And it's also good for non server applications.

  • This is not good for non server applications like game engines, mobile applications, stuff like that.

  • So, like I mentioned earlier when I mentioned uh, not blocking events and asynchronous I know what that means is so say you had a Web server that read a file from the file system.

  • Incentive back down to a client's browser.

  • Who is requesting it that say it was an image.

  • Sometimes reading files from files over takes time so you could have a very slow disk and it could take a couple seconds.

  • So person A, with their Web browser, makes the request for that image.

  • Person be with another Web browser, then makes a request to the same Web server, but they request something that's a lot quicker.

  • For instance, they want to get the information about a user.

  • They wantto look at the profile on Twitter and for some reason that takes longer than reading that image from the disc does for personnel.

  • So person A makes the request and because the input output and noticed non blocking, it basically pushes that off to the background by itself and continues that that discreet while person be can really make a request for that user information, pull it back down and it gets pushed back down to their computer just fine.

  • Then, when person A When the images done loading from the disk, it gets sent back down to personnel.

  • What what happened?

  • And something that was not was not non blocking her was blocking is one person a made the request for that image?

  • The server would stop everything until that image was read in from the disk and person be would be stuck waiting to see the profile information, even though that's a lot quicker than what person A is trying to do.

  • So they'd have to wait for person a to get done before they could do anything in.

  • That isn't good, because these things are running on your servers and their clients on completely separate computers, completely different parts of the world.

  • You don't want them to have to think.

  • Oh, this is going slow because person over here is doing something else like that.

  • That's not gonna I'm gonna fly with them.

  • Really?

  • Do we have any questions about not walking Io or when you would or wouldn't want to use node was an example of something that would be secret.

  • This okay?

  • The question was, what's an example of something that would be synchronised versus why just mentioned that something that was a synchronous So reading that image from your disk on your computer could be synchronous but no does it in an asynchronous away.

  • So what?

  • That what I mean by that is when you when you make that request for that image like I said, node pushes it off into the background, continues doing other things.

  • If it was synchronous and you could read, you can note you can actually read and you read some from the file system in a synchronous way, but a lot of what it's like default asynchronous.

  • If it was synchronised, it would stop everything else down the chain from happening so all their users, so the things that are in synchronous could also be synchronous it just depends on what you what you wanted to dio and with No, the synchronous stuff is kind of the default.

  • So anything that is a singer, this could also be synchronous.

  • What other questions do we have?

  • All right, I have more code examples.

  • These air actual web servers this time.

  • So the 1st 1 is gonna listen for I'm gonna show you two applications.

  • They're both pretty similar.

  • The 2nd 1 Just a little more in depth.

  • The 1st 1 just listens for and events on the server.

  • The 2nd 1 listens for specific types of events and does specific things for those.

  • All right, so I will run through this code first.

  • The first line of this code, um, is requiring in the http module bits of code and node that are provided by something other than your application other than the scripture in are called modules.

  • So you can run a module in store in your application?

  • Uh, no.

  • Provides a set of built in modules.

  • Http being one of them.

  • There are third party modules that you can install through tools that will discuss later called, We'll discuss later called in P.

  • M.

  • But this is how you require them.

  • But it basically gives you access to everything that's in on exported from this http module in the variable that I'd call it GDP.

  • So the first thing we'll do is create a new server.

  • Http has a function on it called Create Server and you give that function a call back.

  • And what that means is, any time anybody is make makes requests to the server, this highlighted code will execute, and I'll show you in a second what this highlighted could actually does.

  • We signed that server to the variable server because we do some with it down here.

  • Here we are, creating a port, and I wanna be ready.

  • Miss this locally with nothing else on my computer s o.

  • The example supports.

  • Won't you have to define a port?

  • But a port doesn't matter that much in this situation.

  • But what a poor is It is basically a way to tell us specifically what you're talking to on a computer.

  • So there's a bunch of there's a bunch of network imports open on my computer right now for different reasons.

  • So I had five note applications running on my computer.

  • They can all run on the same port.

  • So one around 8000.

  • Well, don't run on 1000 and 11 8002 and so on.

  • And you may request to that specific port.

  • That way, when you make a request, you know what what you're talking to.

  • And the note applications know which which of your service is needs to respond.

  • So the server, very polite to find up here.

  • When I created that server, I'm calling the dot Listen, function on it.

  • And what that tells you is it tells the server to begin listening for network requests against it.

  • I passed the port and then I passed out a call back.

  • So this code is executed when the server begins listening.

  • So the first thing Mission run and I run.

  • This is this console log right here saying the server started to listen on port and the port number.

  • So let's go ahead and run it.

  • We're gonna rent the same way.

  • No.

  • And then the name of the fire, which is events over, Doctor.

  • Yes.

  • So and there we go.

  • The first thing and it is a server started on Port 8000 and then nothing.

  • Application didn't finish.

  • Still, just sitting there open.

  • Well, what's going on?

  • What it's doing is is waiting for me to make network requests to the server.

  • And when I do make network requests, this bit of code is going to be executed.

  • So let's go ahead and make a network request to do this.

  • I'm gonna use a tool called Postman and everybody kind of see that light team.

  • Okay.

  • Is that better?

  • I don't You can't.

  • I haven't seen a weight of human plus man.

  • I will very explicitly talk about whatever things happening.

  • So I'm gonna type local host.

  • Local host is my my computer.

  • So this is where you would type the website you're talking to, like google dot com or whatever.

  • And just local host is my machine and then the port.

  • So I know what application to talk to.

  • I'm making a get request, which is an http method We'll talk a little bit about Http.

  • As we go through these examples get is one of the requests you can make through http, which is a networking protocol.

  • There's a bunch of other ones you don't use most of them.

  • Most of the time.

  • Use a couple of them.

  • I don't want to go ahead and send that request.

  • The response is a Jason object, which, if you're familiar with Java script, you're probably familiar.

  • Chase on.

  • But does anybody not no, not know what Jason Jason isn't would like me to go into that?

  • Awesome.

  • So what Jason is is a way to basically collect unorganized data.

  • So say you have a bunch of information that you want to send around between applications or sent to a user U S.

  • Senate and Jason's a good form to send that in.