Check out a free preview of the full Introduction to Node.js course:
The "What is Node.js" Lesson is part of the full, Introduction to Node.js course featured in this preview video. Here's what you'd learn in this lesson:

Scott defines Node.js as an environment for running JavaScript outside the browser. What that means in context, as well as what design decisons were made are discussed.

Get Unlimited Access Now

Transcript from the "What is Node.js" Lesson

[00:00:00]
>> Speaker 1: So what is Nodejs? Someone give me your definition of what is Nodejs. Scott Fox, you knew I was going to pick on you. [LAUGH] Like how could I not? Dude I like saying your name. Scott Fox, it's like a comic book character, it's awesome. What do you think Nodejs is there's no wrong answer.

[00:00:20]
>> Speaker 2: Server-side JavaScript.
>> Speaker 1: Server side JavaScript you'd be right, anybody else?
>> Speaker 3: Port of the Chrome V8 engine to desktop.
>> Speaker 1: Yeah, that's also true. He said it's a port, Victor said it's a port of Chrome's V8 engine yo desktop, yeah. Anything else?
>> Speaker 4: Dependency manager?
>> Speaker 1: Nodejs does have a dependency manager, yes.

[00:00:45] So that is also true.
>> Speaker 5: It's a runtime environment for JavaScript outside of the browser?
>> Speaker 1: That is very true, it sounds like something narrow for yeah, [LAUGH]. That is very true yeah, all that is true. The point that I was trying to make it's like and it's like, what?

[00:01:02] It's like, it's this environment? It's this runtime? It's also a language, it's a server, what is it? It's all those things, okay. So on my slides, you'll see at the top of every slide, I'll put a TLDR about what this slide is, it's meant to be very small like that, but that's what this slide is gonna be.

[00:01:19] So what is Nodejs? Basically it's an environment to run JavaScript outside the browser, that's basically what Node is. It's an open-source runtime, and yes, it's not one of those open-source projects where it's like, it's open-source, but really, you can't really work on it. Yeah, it actually is open-source, there actually is a Node foundation of, smart people got together, and they wanna organize this thing, and do releases and stuff.

[00:01:42] Because there was a lot of drama in the past, and if anyone wants to hear about that, I can talk about it later. But they have a foundation. There's a lot of people helping it. A lot of big companies contributing to it. It is open source and when I say runtime, I'm thinking of an executable, right.

[00:02:02] So if you're writing code in bash you're in a bash runtime. If you're writing code in Ruby, you're in the Ruby runtime. So this is like it's own runtime, it's its own environment that's self-encapsulated, you don't have to do anything. It is built on Chrome's V8 JavaScript engine.

[00:02:18] If you don't know what that is, Chrome's V8, so most every browser have their own JavaScript engine, on how they actually parse and run your JavaScript. Chrome's one is called V8 and it's just their compiler that they use to compile your JavaScript down to machine code so the actual machine can read it.

[00:02:38] Chrome's V8 has been one of the best out there. So the creator of Node decided to take that out of Chrome, rip it out and put it somewhere else. And that's what this is built off on. So that's why you can write Nodejs in JavaScript because it's built on the same engine, it's V8.

[00:02:53] There's other JavaScript engines and browsers like SpiderMonkey, which what is that a Firefox. And then Safari uses, I can't even think of Safari's right now. I've been somewhere else. But yeah, there's different types of them, but Chrome has been pretty good. So that's the one they're using. It was created by Ryan Dhal in 2009.

[00:03:13] So Nodejs goes way back. In the early days, no one gave a damn about Node. Everybody was like whats the point, it's just JavaScript. This was when JavaScript was considered Like a kid's language almost it was like, it's JavaScript. Like you're not serious, you know that was back in the day where you have like engineers and then you had like the marketing person that did JavaScript right in the did jQuery or something like that.

[00:03:37] So he took that and he's like actually there's this pretty cool stuff and I wanna do and boom the kind of just blew up Ryan Dhal currently works at, Google right now I believe on some machine-learning stuff. I wonder, did I spell his name right? Maybe it's D-A-H-L.

[00:03:53] But, Ryan Dhal he's got a lot of good talks about node and stuff. So I would check out some of those talks. Really smart guy. Since it was created it has evolved. Like I said, it kind of started off as just this basic thing where it's like yeah, it's not really gonna be serious.

[00:04:12] But now, like you can pretty much do everything in Node, and I would say there is a lot of things that contributed to that. But I would say some of the biggest things are the fact that it has a really big thriving community, probably one of the biggest communities In the open-source world, it comes from Node.

[00:04:27] Most of the stuff that happens first, happens in Node from my experience. If it's gonna happen anywhere, it happens here. And a lot of runtimes and languages and frameworks and stuff kind of look at what Node is doing and try to build something similar. And then all these huge companies like Facebook and Google, they are constantly building tools and frameworks around Node because they know that there's so many developers there.

[00:04:49] So it has evolved way past what people would have imagined. And it has enabled us as engineers to basically, like I said earlier, replace like a whole team. If you are an engineer who worked at a company whose entire stack was JavaScript, you could do everything there. In the given amount of time, you could create the desktop app.

[00:05:10] You could create the Web app. You can create the mobile app. You can create the build tools. You can create the server. You get all of that in JavaScript. And you know, if it's all just JavaScript, then you should know how to do all of it. Should, but it's a little different.

[00:05:22] So yeah, it's pretty pretty awesome. Any questions on Nodejs. Yes.
>> Speaker 2: From your perspective. How does it compare to other back-end environments like you mentioned you started in Ruby and kind of moved over.
>> Speaker 1: Although Java scares my primary language. I love JavaScript is definitely not the easiest language to learn at first.

[00:05:43] I still think python or Ruby or just way easier to learn in my opinion. So the language itself I would say Java Script like it's not the easiest to learn for beginners. So that comparison to java script is not that good to start with. But once you get past the language.

[00:05:58] You just looking at the runtime and the community and the tooling. It's just far beyond anything else like just way past any other back in and run time ever is like Ruby has it's own pocket management Payton has own pocket manager but nothing come closer like what JavaScript and what manager.

[00:06:17] And we'll notice that with their pocket manager and the community around that like I can go on Google, like I see the point now I, if I need to do something note I don't even think about making it, I know this is somewhere, somebody made this. And I just go look, and most of the time I'll find it, 90% of the time it's there.

[00:06:33] Even if it's outdated, I can just look at how they did it and kind of do my own thing, but that right there has just been invaluable to help me build things faster and grow faster and actually learn. Because I remember thinking, when I was using Ruby and Python I almost never looked at people's source code to understand what they were doing.

[00:06:50] Where's a node? I look at source code all day. I would just go look at framework source code to figure out algorithms. I just go look at all this stuff to understand what's going on because it wants you to. That's what the community wants. So I would say it's a lot better than that.

[00:07:04] And to me, it's also just more flexible that you can actually just deploy in JavaScript, because if you're building a client-side Web app which is obviously gonna be in JavaScript in your servers in JavaScript. There's some things you can do to interrupt like, you know back in the Ruby days.

[00:07:19] If you were trying to pull your application on the front end like you had to use like ERB and like sometimes you know, I mean is invented for Ruby people. It was like all this stuff and it was just never felt right? Whereas JavaScript feels like it's just one app.

[00:07:32] It's just one thing together. And that to me is just amazing. So once you get all the flow and everything going in my experience it's just way better than everything else. Not even close.
>> Speaker 1: Any other questions? Yeah.
>> Speaker 2: It sounds like Ruby. I did Ruby on rails, and I did a multi tenant database with apartment, I don't know if you've ever played with that.

[00:07:54] Is there anything similar to that in Nodejs?
>> Speaker 1: So Nodejs is not a conventions-based platform, so Nodejs has no idea what database you're gonna use, or it doesn't hook into your database and it doesn't provide any tools for your database. So that would have to be up to the database that you choose that does that.

[00:08:11] So if you wanna do some type of multitenancy, then yeah, you would have to figure that out, because Nodejs it's like, it's definitely not a convention based thing. Where as Ruby's like the full package, they got every single thing. Yeah, Node is not like that, Node is just like, here's an environment, here's some gobbles, good luck, right.

[00:08:30] [LAUGH] That's no, so yeah, there are not conventions like in Ruby. So you are used to that, you're not gonna get it. But the beauty of it is, that the community has built things like that. So although Nodejs doesn't come shipped with something like that, the community is like whoa.

[00:08:44] I used to have this in Ruby so I made it. They have the concept of scaffolding and templating and all this other stuff. So most of the time there's something there, and if not, it's pretty simple to make itself. So that's the beauty of it. You got one?

[00:09:00]
>> Speaker 4: So according to a lot of Reddit comments, they say Nodejs is not suitable for the run intensive applications. And you might just choose python or even php.
>> Speaker 1: Yap.
>> Speaker 4: Is that still the case?
>> Speaker 1: Yeah, so we're gonna dive a lot into that later, and in one of the exercises you'll do, you'll encounter that.

[00:09:22] But the short answer is, that is true. Yeah, a node is not I would not recommend it. Even the creators of Nodejs, they put out a blog post not too long ago that was like- Don't use it for this! It's really not meant for high CPU intense operations.

[00:09:37] Like if you are doing some type of large arithmetic, machine learning or reading the file systems synchronously. Things like that, it's not meant for that. And that's just the nature of how JavaScript is. It's asynchronous, it's single-threaded with an event loop versus something like Python that's multi-threaded where everything is ran on its own thread and it's blocking.

[00:10:00] So because of that, it enables Node to be high on concurrency. But not that efficient on like high CPU bound task. So there's things you got to do to get around that but sometimes you can't get around and you have to use something like python like if I was doing like some type of machine learning I probably wouldn't do it in note, but I would have no be my API.

[00:10:20] And then have it talk to my machine learning thing over here in Python or something like that. So yeah, it's definitely not the silver bullet for everything. But for most of what people do on the web you can get away with using Node.
>> Speaker 1: Any other questions?
>> Speaker 2: I'd just comment that it's gonna evolve.

[00:10:41] And if people want that, eventually it will happen.
>> Speaker 1: That's true, yeah, so again it's open source, there's nothing stopping anybody from doing and trust me, I've seen some crazy stuff out there that people are making that you can take advantage of. You can even, I mean and there's models and sort of Node.js where you can enable Node to take advantage of all the codes inside of a computer.

[00:11:01] You can cluster it, that's what they call it. So there's definitely things you can do So it really is up to you but by default, no, it's not for that. But you know, you can throw money at any problem it'll fix itself. So, you know, if you want to scale something skelet, you know, so it's up to you.