Introduction to Node.js Creating with Node.js
This course has been updated! We now recommend you take the Introduction to Node.js, v2 course.
Transcript from the "Creating with Node.js" Lesson
[00:00:20] But, it can do pretty much anything those run times can do. So, things like tooling, that includes building frameworks, like have you heard of Webpack or Gulp or anything like that, those types of things. Automatons which also again are like Gulp and Webpack or like I want to automate this deployment, or push this to get, or version this.
[00:00:42] Node is just so amazing at automations. I usually, so I collect sneakers, and when sneakers would launch on certain websites, I would just like literally an hour before, I would just build a script to just go buy them for me. So I don't have to do it and no like takes like an hour just go on the website like okay, here's what it looks like and then I'll just crawl it in node to buy the sneakers for me.
[00:01:02] Like I could not have done that without note. So it's just like you can pretty much build any type of automation you can think of so, it's pretty awesome. So it's great for tooling. It is really great for API that I would say. It's in my opinion probably like, what are the best run times for creating APIs.
[00:01:20] Go, Go is pretty good too. But I would say Node is just more excepting than Go for like creating any type of API. So this includes like REST APIs GraphQL APIs, if you use GraphQL. Realtime APIs are like web sockets, especially Realtime APIs, and that's just because Node enables high concurrency because of its event loop architecture and we'll dive into that a little more.
[00:01:43] But it's basically the same as the browser, it's just single threaded event based. So it's really great for that because it can handle so many requests at once. CDNs, this is kind of new, and I wasn't sure if I wanted to put this here yet because this is a new concept that's coming soon to an app near you.
[00:02:02] But basically a CDN, this is like a network of computers, right? Around some space, whether it's the world or a nation, or a consonant whatever, it's a network of computers, and you host your assets on that network. So therefore those assets are delivered to your customers as fast as possible.
[00:02:49] You can do some crazy stuff with that that you couldn't do before. Sharable libraries, so again I said the community is pretty awesome. And what makes the community awesome is that people can create these libraries and modules and then share them with people. But also that can be pretty scary.
[00:03:06] [LAUGH] But that's what makes it pretty awesome like, okay, cool. I'm gonna build this, my tenth REST API and I'm so sick of having to rebuild it from scratch every single time. Then like, okay cool, just go download this one that everybody uses and has great documentation. And you're good to go and then somebody's supporting it.
[00:03:24] And I've never seen so many open-source developers just quit their job and make money off open-source, then before Node. It just wasn't a thing, you couldn't make money off open-source before Node came, it was just, you did open-source on the side, or either consulting. You would create Ruby on Rails, and then you would go consult for it.
[00:03:42] But no, these people just literally fix issues all day on open-source that they created, and they make money. And that's because so many people use these things. The community is reliant on these packages that people can just make money off of the code that they create for free.
[00:03:55] And its all donation based, it's like may people just give then money, like, here you go take this money, so it's pretty legit. The desktop applications, so there is like three of four different runtimes that are like subsets of Node that you can use to create desktop applications.
[00:04:12] So Electron.
>> Scott Moss: I can't even think of the names of the other ones there are so many of them. SWJS, but they enable you to create native desktop applications with web technologies and it's all powered by Node, which is pretty fantastic. So again you don't have to use cocoa pods and like all this stuff to build your Mac app or your Windows app.
[00:05:12] So you can pretty make whatever you want here and get away with it. In fact, before all this IOT stuff was happening, me and my son, we actually had a 3D printer and we printed out. This box that would go on a wall, and all it would do, it would just tell us if a door or a window was open in Morgan Freeman's voice.
[00:05:30] [LAUGH] We made that with just Nodejs and it took us two weeks. And then a week later they came out with I was like [SOUND], okay.
>> Speaker 2: What did Morgan Freeman say?
>> Scott Moss: [LAUGH]
>> Speaker 2: The door is open.
>> Scott Moss: Yeah, like, the door is opened. The front door is closed.
[00:05:45] We did that to the best of our ability. We had, like, we went on Fiverr and found somebody who imitated his voice. [LAUGH] I sent Adam to hit record. We paid him $5.00 for it. It was pretty cool.
>> Speaker 3: [LAUGH]
>> Scott Moss: [LAUGH] and we did that. It was really cool, we designed it, we put lights on it and everything and it was all powered by Node.
[00:06:05] So it was an awesome project. Yeah, pretty much anything because Node is on everything now. It literally is on everything. You can make your microwave powered by Nodejs if you want to and build an app for it if you need to. Mark's got this Twitter that he follows that he sends me to, it's pretty funny.
[00:06:26] But they do that a lot. So yeah, you can pretty much make anything. So, if you can convince your company to use Node then it would enable them to do all sorts of things. And it would just make you look like a badass, because you'd be doing all of it.
[00:06:38] So yeah, highly recommend doing that. Any other questions, any other ideas you might have had? Yeah.
>> Speaker 4: So, you're not looking at other server-side languages, like PHP and Python. A lot of libraries are core, you don't really need to depend on a lot of libraries.
>> Scott Moss: Yeah.
>> Speaker 4: What scares me sometimes is a billion packages that came installed, just on load step, right?
>> Scott Moss: Yeah.
>> Speaker 4: How reliable is that especially in large scale production of applications? I mean do companies really use those dependencies or do they write their own?
>> Scott Moss: Yeah, so two parts of that question and one part is, so the internal modules. So Node does have internal modules that people use, some are like you just cannot live without, and you're gonna really work with some of those.
[00:07:23] But it definitely doesn't get you far right eventually you need to do something else. So you do have to rely on a community and you're right, it is pretty scary and to answer that like how reliable is it? It depends on who made it because there's like node isn't doing anything to check.
[00:07:39] There's code to make sure it's not malicious, so it will be up to you in the community. So there's just some things and I'll show you how to figure out what modules to download. There's just some steps that you have to go through to make sure that you're not getting something that's bad.
[00:07:51] And that's kind of why I wasn't able to just go look at source code all the time. So I'm pretty sure, like, this is happening, this is happening. But at the end of the day, what I found out is that, if there's tons of people in the community using something.
[00:08:01] And there's a healthy GitHub repo for this project, there's tons of issues that are being closed, there's been activity in the last week, there's really good stars, there's really good companies using it, chances are it's pretty legit. But if you're downloading something from three years ago that was created by someone who deleted their GitHub account and it's like nothing on there, like probably not.
[00:08:23] So it really depends on like, it's a case by case basis, and big companies do use this. I've worked with huge companies, like some of the top companies in the world, and yeah they'll just get on there and NPM install stuff. Where as other companies won't, other companies won't do that and they have to go through every single module.
[00:08:39] To check to make sure it's got the right license on it, they're not competing and stuff like that. But at the end of the day, everybody seems to be open to the idea of exploring modules created by the community in some way. And like I said, they might have some process in how they actually get in their app, but yeah, it's a pretty common thing.
[00:08:56] I haven't worked with or seen a company that, only makes their own things ever, I haven't seen it. I could imagine that sucking really bad, so yeah. Any other questions?
>> Scott Moss: We got one, Daniel?
>> Speaker 5: Will a company sort of maybe fork, if they're like, okay, this works to now.
[00:09:19] I did npm install, it worked now. But I don't want to be responsible for whatever weird changes this person is gonna do to this library. I'm gonna fork it and now we're just gonna have our own copy of like express or whatever the case may be.
>> Scott Moss: Yeah, there's many ways to do that, so forking is one.
[00:09:35] So people will fork it when not only do they want to not have future changes and bugs. But because they wanna add additions to themselves, so that's when you would fork it. But if you just want to be excluded from any future changes, then the package manager would actually handle that for you.
[00:09:51] You would just tell the package manager, don't download any other versions, lock it to this version. And there's a thousand ways to lock a version. So yeah, that really pays, I find myself forking stuff all the time. In fact I'm at the point now of when I go create a new module I almost don't need to start it from scratch.
[00:10:05] I'll go find something that already like started it and like nobody finished it. And I'll be like this person started and kind of gave up on it. So I'm gonna take what they had and I'm gonna finish it or I'll take the idea that they had and I'm gonna finish it.
[00:10:16] So I'll do that a lot to get things going so yeah that is a very, very common thing. In fact, that's what happened to node. Somebody forked node, and it was a big deal. Yeah, we can talk about that later, but yeah. Luckily because of all that drama node is even better now.
[00:10:34] But before that it was like [SOUND]. Now it's like, okay, it's amazing. And that's because somebody pushed their hand and forked it and scared everybody. So that was pretty awesome.