The Hard Parts of Servers & Node.js

JavaScript, Node & The Computer

Will Sentance

Will Sentance

Codesmith
The Hard Parts of Servers & Node.js

Check out a free preview of the full The Hard Parts of Servers & Node.js course

The "JavaScript, Node & The Computer" Lesson is part of the full, The Hard Parts of Servers & Node.js course featured in this preview video. Here's what you'd learn in this lesson:

Will explains the role of JavaScript and Node within a server and differentiates between the two roles.

Preview
Close

Transcript from the "JavaScript, Node & The Computer" Lesson

[00:00:00]
>> Will Sentance: Sarah Rose's Mac, Sarah Rose's Mac opens, what she open twitter.com/node, by the way people, I literally searched for a nice screenshot of tweets. So I thought there's something clean and nice like node and twitter is a horrible place. Then both voted tweet on there was, if you don't like node, die.

[00:00:24]
>> Speaker 2: [LAUGH]
>> Will Sentance: So I couldn't do a screenshot, so we have to just imagine. That was the most upvoted tweet, 300 likes, if you don't like node, you're gonna die or something like that. What is this place? Anyway, all right, so Sara Rose, Mac, Mac, okay. So let's start now doing the colors, cuz we're going to keep track.

[00:00:45]
Of, we're gonna keep trying of each of these things by using different colors. Let's have, node is green isn't it everybody? Let's do green, okay. Okay, and then we'll use black for JavaScript and we're gonna use blue for our computers internal. So okay, Sarah Roses, Mac sends off an internet message it lands at?

[00:01:20]
It lands at Twitters, computer Twitter's, yeah, Twitters computer.
>> Will Sentance: There it is, okay, it lands here. Up here, folk, is where we're going to run or write the JavaScript code that we're running. But her inbound message definitely does not arrive in JavaScript. Remind me again, Zeb, where it arrives?

[00:01:49]
>> Speaker 3: Where does it arrive, the inbound message?
>> Will Sentance: Yeah.
>> Speaker 3: Into a node.
>> Will Sentance: No, no.
>> Speaker 3: [CROSSTALK] network.
>> Will Sentance: Into the network card, effectively, right? So here is gonna be our computer internals, or internal features. And this, folk, this is where our inbound message arrives. It's got all the data we need to be able to send back to say Rose, the exact tweet she needs.

[00:02:17]
But here's a problem [SOUND] we want to write JavaScript code to access it because we unfortunately didn't learn C++, no, exactly, we don't use C++. So what are we gonna do? Your name was, man?
>> Charlie: Charlie.
>> Will Sentance: Charlie, how am I going to get access? Am I gonna try and write JavaScript codes directly interact with these computer internal features?

[00:02:44]
No, what am I gonna do instead?
>> Charlie: You'll need to go through some C++ code.
>> Will Sentance: Absolutely spot on, I'm gonna have node, very light green, here we go, node C++ built features, there they are, and we're not going to try and access .The computers internal like its network feature, lets have its network feature there, its networking.

[00:03:17]
We're not gonna try and access those directly from JavaScript, we're gonna access them indirectly by using labels. In JavaScript, they'll look like JavaScript functions if for reality commands to nodes C++ features. I would say this node, some of this stuff is done in JavaScript as well but they're both the interface with the confusing titles in the C++.

[00:03:44]
And from that, we will then effect and grab the message and pass it up. Now this may seem like a crowded one as on the Java Script old people the vast majority of the interesting stuff of nodes hard work is all happening down here. So we better understand this intimately but also unfortunately.

[00:04:05]
Well he's better understand how his work minutes on the code but know how it's working. Me maybe how to understand a bit about what's going on here what is a socket for example, but we also better understand how this language is working. All right people so on that note here we go this is reiterate this c++ many features that let it directly interact with the operating system.

[00:04:29]
That's what you call the computer's internals, directly. JavaScript doesn't, by the way, just to be clear, C++ isn't gonna go sit on the network card itself, it's gonna interact with abstraction layers of the operating system as well. Things like you will learn all about this other stuff a little bit later on but hold that thought for now what is a combination known as nodejs.

[00:04:56]
I know it should be called node js C C++ it for real it should be it should be acknowledging. All the hard work here done by C++ and not by JavaScript. JavaScript controls node C++ features controls computer features, okay. Got it, good, rewind. We had better understand JavaScript's execution model if we're then gonna understand node.

[00:05:18]
It's a language that does three things. I mean, it does more things but three main things. And one of them isn't even much in JavaScript, it's mostly using, mostly involves a lot of help from C++. One, it saves data, numbers, strings, arrays, objects, and functionality. That code is gonna be run later on.

[00:05:42]
Two it uses that data by running functionality saved code has not been used yet, but he's later on it. And then three has a ton of built-in labels that are gonna trigger node features that are built in C++ to use our computers internals. But let's see these first two in action.

[00:06:04]
The first two things that JavaScript does by itself, independent of node, saving using data. Let's see the two things that JavaScript does by itself, without the help of node background C++ features, so we're not doing that yet. Because we'd better understand this JavaScript language really intimately. If we are gonna know how it's gonna interact with this feature down here then I would C++ we just.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now