Previous Lecture Complete and continue  


Most systems don't work in isolations. We want to integrate with other systems like databases and third-party services using OAuth, RESTful or SOAP APIs. So Node.js provides all of that, the various modules or packages that you can find on npm.

The most common databases are supported. There are a lot of drivers and a lot of libraries that you can use to connect to those databases. Now, how Node.js fits into the web development architecture. Typically, Node.js is used to build RESTful APIs, and then you would use Single-Page Application like Backbone, Angular, that's called a M.E.A.N stack: Mongo, Express, Angular and Node, Ember, React or any other MVC framework, Front-end MVC framework.

Now, it's still possible to build the traditional BoB application with Node.js, but most of the times, we are building single-page applications, and using Node.js for APIs. So, for server-side rendering or for traditional application that renders everything on the server-side, another name would be, "Thick server" versus single-page application or "Thick line."

You can use pretty much any template engine that's available on the browser. I'm pretty sure, it's important to Node.js, but too because it's so easy to reuse that code and that library on the server-side. One of my favorite libraries is Jade and then Handlebars, it's very similar to HTML. It uses curly braces. So the beauty of the RESTful APIs and the JSON format is that you can build your API once, and then you can reuse that API across different platforms.

You can use it for mobile, for desktop. You can use it for internet of things, for smart watches, etc. So what is ECMAScript? I mentioned ECMAScript, a few times already. It's a standard, and the language specifications. So each browser has a different implementation. Few years ago, the discrepancies were huge. Now, they're getting more and more similar in terms of how each different browser implements this JavaScript, a language and ECMAScript center.

So, think about Node.js as another implementation, like we have JavaScript and Firefox and Safari, and the different Node.js, it's different implementation. So most of the JavaScript is the same, except for a few differences and that we will cover in the next lesson. Things like Modules, Scope. Window is not present in Node.js. We have Global and Process and then Process has a System information.fs, it's a file system Module.

In the browser, we don't have any File System Modules, etc. So, what is Node.js at the core? What is under the hood? Typically, the three main things in Node.js is Libev, which is event loop, and then we have Async I/O, and Abstraction to libEio. This picture illustrates how they interact.

So, the bottom level, it's a very low level. We have C and C++ modules. We have some Node.js bindings in modules like Socket or http or net. And those Node.js bindings interact with V8 directly, with event loop that enabled this non-blocking I/O. We also have Crypto module and other low-level system modules and packages. On top of that, there is this JavaScript interface.

So, if you actually go to the Node.js GitHub repository, you would see Node.js file. That's how the name came. So, we use JavaScript to interact with C and C++ at the core level. These are some of the patterns, how Node.js and its frameworks evolve. So, we have SaaS, we have Mobile, Internet of Things right now. And here are some of the framework categories. So, we started very small, we only used core modules. Then we had some convention. We shifted to configuration over convention. And now we have ORM and Isomorphic libraries.