Node.js Getting Started | Hulya Karakaya | Skillshare

Node.js Getting Started

Hulya Karakaya, Frontend Developer

Node.js Getting Started

Hulya Karakaya, Frontend Developer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
19 Lessons (1h 10m)
    • 1. Welcome

    • 2. Class Project

    • 3. What is Node.js?

    • 4. Frontend vs Backend

    • 5. How to Install Node?

    • 6. REPL

    • 7. Tab and underscore

    • 8. Execute javascript code

    • 9. Browser vs Node

    • 10. What Node is NOT

    • 11. Client Server Communication

    • 12. Threads

    • 13. Event Loop

    • 14. What can you do with Node?

    • 15. Advantages of Node

    • 16. What Node Brings

    • 17. Drawbacks

    • 18. Interview Questions

    • 19. Review and Closing

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Node.js is a server-side JavaScript platform that allows developers to build fast and scalable applications using JavaScript outside of web browsers. It is playing an ever-wider role in the software development world, having started as a platform for server applications but now seeing wide use in command-line developer tools and even in GUI applications, thanks to toolkits such as Electron. Node.js has liberated JavaScript from being stuck in the browser.

 What we will learn:

  • An introduction to Node.js
  • What you can do with Node.js
  • Why you should use Node.js
  • How To Install Node.js 
  • How Node.js works
  • Event loop and concurrency

 Who this course is for

Server-side engineers may find JavaScript to be an excellent alternative programming language. Thanks to advances in the language, JavaScript long ago stopped being a simplistic toy language suitable only for animating buttons in browsers. We can now build large systems with the language, and Node.js has many built-in features, such as a top-notch module system, that help in larger projects.  

Developers experienced with browser-side JavaScript may find it attractive to broaden their horizons to include server-side development using the course.

It will be helpful to have some experience with JavaScript programming. It is a fairly easy language to learn if you are already experienced with other programming languages.

To get the most out of  this course

The basic requirement is installing Node.js and having a programmer-oriented text editor. 

Meet Your Teacher

Teacher Profile Image

Hulya Karakaya

Frontend Developer


Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Welcome: Welcome aboard everyone. My name is Julia. I am very excited to present to you my course NodeJS, getting started. Curious if NodeJS is right for you. Maybe you have heard of modulus, but Alan quite sure what it is or where it fits into your development workflow. In this course, you will learn what knowledge bases and how you can use Node.JS to run JavaScript applications and cold outside the browser. Prerequisites for this course are usually known JavaScript. You should be familiar with JavaScript and ES6 concepts. And you should know command line. This class is for server-side engineers, Ola course experience with browser-side JavaScript, and almost anyone who wants to then NodeJS. Why is this class useful? You will be able to interact with the server side of JavaScript and run JavaScript without the need for a browser. What you need, you only need a programmer oriented text edited. This course is beginner friendly and I will be using Visual Studio Code is for the text editor. What we will learn. We will learn what mode is Chrome V8 engine, client versus service. How things down mode, no dipole environment and how to execute, not, not binary, browser versus not. We will compare browser versus not how mode works. Iran proband concurrency, node architecture, non-blocking IO, single thread. What you can do with not Libya and advantages and drawbacks of null. I know these are looking like gibberish, but at the end of this course, you will know all about these. By then of this course, you will be comfortable creating and executing code for NodeJS. And you'll be able to decide with a NodeJS is the right tool for your project. I hope you will join me on this journey to learn all about nudges in this course. See you inside. 2. Class Project: As for the class project, you will install NodeJS on your machine. You will wait for your installation mid note, they should be. Then use them on the re-plan. Write some JavaScript. After that, use the not CLIA executable against ab.js file. I want you to take screenshots that you install NodeJS, you use not the ripple and you use not CLIA executable. Just add your screenshots in the class project. And big news, I also added some bonus interview questions. So I want to try the questions. Try to answer two questions and you cache the results in the class project. Okay, we can go. 3. What is Node.js?: Let's start at the very beginning. What exactly is no JS? Js Runtime powers backend servers of big companies like PayPal, Netflix, and even nasa. So in this course we will learn about this very popular runtime and get you comfortable writing called four-node. So nowadays is a JavaScript runtime or an environment that runs JavaScript code outside of the browser. What is the runtime? Runtime converts code written in a high-level human-readable programming language, and that composite down to coat the computer can execute. It's built on Chrome's V8 JavaScript engine. We will learn about the sun. And note was created with the goal of building web servers and web applications in JavaScript. But it's a powerful and flexible environment that can be used for building all sorts of applications. It's created by Ryan Dahl in 2009. At the time, Apache HTTP server handles the things that NodeJS 10, 100 now, but with less efficiency, especially Apache couldn't tackle concurrent requests. What is concurrency? Concurrency means like UV can execute multiple tasks at the same time, but not simultaneously. For example, we can work with two tasks in overlapping time periods. So NodeJS was created and it evolved since its creation to allow developers to build almost anything. You can build scalable network applications using JavaScript on the server side, like many big companies are doing now. It's open source, it's server-side scripting. Nadh is usually defined as JavaScript on the backend. Before note that wasn't a commoner easy thing. Javascript throws me in the front and thin, yet we were only using for user interface. The server-side code produces dynamic webpage content like persistence. For example, when we go to Twitter, are two beats going eval, they always stay because of the persistence of data. Now, let's speak about Google Currents V8 JavaScript engine. The execution of JavaScript is not done by node at all. It starts with a Virtual Machine, VM like V8 or chakra. Sa node is just the coordinators, is the one who instructs the VA and VM like V8 to execute your JavaScript. So we can say NodeJS is a wrapper around the JavaScript engine called V8. And this is powering many browsers including Google Chrome, Opera, brave, Vivaldi, and Microsoft Edge. It was designed with performance in mind and is responsible for compiling JavaScript, direct it to native machine code that your computer can execute. And not V8 is written in C plus plus. Node is also written in C plus plus, but we will not learn C plus plus in this course. So V8 is the default VMI not, but we can run node with other VMs if we need to, if we want to. So how it is working. Like we said, JavaScript engine V8 takes Jevons secret code and compiles it down to the machine code that your machine can actually execute. The V8 JavaScript engine in turning the compiles JavaScript using just-in-time compilation. V8 is using just-in-time compilation to convert our code to machine code. So when we write JavaScript code and execute it with the node command, node will pass your JavaScript V8. V8 will execute that JavaScript and tan note that what the result is and node will make the results available to you. Okay, Let's move on. 4. Frontend vs Backend: Before we learned about node, I want you to understand what is the difference between client and server. But it's client-side. And server-side. Client-side is our front-end code, like our HTML, CSS, and JavaScript. And what can be different and it can be browsers, desktop apps, mobile apps, mobile devices, appliances. It can be even the controls in your car and modern fleets screen. For example, this is the front end of the fridge. This is like this village is coming between those 10 tablet on the on the door. Audio, microwave buttons. It can be anything. It's about user interface and user interaction. Basically, it could be an interface where the user needs to read and interact with an intelligent device. It refers to the code you write that results in something the users see in their web browser. Client side code typically includes JavaScript use to animate the user experience whenever pages loaded. For example, to see something to change the background all with JavaScript, like on the far user interface. What about server side? It's our back-end code. Servers are behind the scenes of all web applications. We can't see this in action. With the servers are client-side data comes. For example, this is the front end code. We can see the, all the HTML and CSS. And this is, our data is coming from Network tab. For example, I got some data and it's given me like some responses, preview headers. These are all coming from server. We have some cookies. All the data related information is coming from server. So server can be APIs, data analytics, security, reliability databases refers to code used for application logic, how data is organized and save to the database server side code is responsible for authenticating users on a login page running scheduled tasks and even ensuring that the client side code reaches to the client. Here, for example, it can give sometimes 40, 48 hours, 5500 teller separator. So we can use server-side code for storing, accessing and manipulating data. And data is stored in databases, which can be relational databases and NoSQL databases. For example, this is Google's servers. It's storing all the data. Okay, Let's move on how to install NodeJS. 5. How to Install Node?: When you're already running gnawed on your own competence is an exciting step towards becoming a developer. Playing on the non rippled in your own terminal and executing your first local JavaScript program will sit you on your way to building all sorts of exciting projects. So afforded first, we need to install NodeJS. Nodejs website is the easiest ratings tell, but this is the list recommended way of installing, not because it limits your options for having minimum versions of NodeJS. And package managers fall behind NodeJS really cycle in studying global modules with node's module installer, NPM can require the use of pseudo superuser command, which grants root privileges and it's not a good security practice. That's why we will use nvm node version managers. So before installing node first, we will install, install nvm. What about what is an nvm? And not Version Manager is a utility that lets you install different node JS versions and civic flawlessly between them on your machine. You can also use it to update your inversion of NodeJS. Vm is a script based version manager for a NodeJS and VM. And VM is unlike unix like platforms and supports POSIX compliance shells. Posix is a set of standards for operating system compatibility defined by the IEEE Computer Society. There are various advantages to using a version manager. For example, it negates potential permission issues like pseudo van using NADH with MPM. And let's just sit in Node version on a per project basis. So for this, we will go to nvm website. You can check it out here. To install nvm, we will use this command. If curlies installed, it says usually installed, a single command can be used to install and set up in VM. If you are using bash, you need to copy this command. If you are using zs H, You can copy this command. And to verify the installation, you can use Kit installed that SSH bash. If you are using Bash, if you are using COSH, you can copy this command and verify the installation of NVM command dish Vm, VM. If this fails on Linux, close and reopen the terminal or SSH session and try running the command again on MacOS. You can't see this page here. Troubleshooting on Linux and macOS. And to install the latest version of mode, we will use this command npm install Node. Node is the alias for latest version. This will install the latest version of mode. If you want to install the specific version of Node, we can use like 16.14.4, whatever version we want to use, we want to use, we can just replace it here and verify node is install installed node dash, dash version or not, they should be comments. Okay, How will we install NodeJS on Windows 10 and up. For this, we will use Node version switches. Nbs. Here you can see the GitHub link. And we assess the recommended version manager for Windows, HLA and VS version manager is cross-platform, so it can be used on macOS and Linux. But MEM is a lot more popular for macOS and Linux. To install NBS on Windows, go to the Release page and download the MSI installer file of the latest release. You can just follow this link here. It will bring you to this page and installed the MSI installer. After it's installed, opening cmd.exe or PowerShell prompt and run the following NBS add latest, it will install the latest version of NADH. And we said LTS at the latest LTS version of NADH. And we ASUs LTS activated newly installed version, not the SRI verify that node is installed like same command we used in macOS and Linux. Okay, how to not reach node is installed, for example, vanity reach not. You can see like if it's NVM or from no minus coming from that nvm. And if you want to learn how to easily update NodeJS to the latest version, you can follow this blog post. It's giving you all the options. How do, how to update your Node version? Okay, let's move on. 6. REPL: I hope you have already installed Node.js by following the commands that I've just given you. In this video, we will learn how to run NodeJS called. First of all, we can use ripples. And secondly we can use, we can just execute our files. For example, node index.js exclusive file in the same directory called index.js. Generally we will use this use for relapse predictable sequence of steps. What about ripple? Ripple? Ripple means read eval, print, loop is great for trying things out, like think console on the browser. It's like heparin and playground. It allows ease execution of any JavaScript code in marriage Rachel environment. We can just type not command with no arguments. This will bring us the REPL environment. First, I want you to try. Do you have not installed again, not the SRI npm dash v n px stationary. And check which not reach NPM. And which end px. Okay? If these are working, you can use the node command here. Okay? Now let's try somethings like to Glasgow, it's returning false. So this will read our line, evaluated, print the result and loop over these three things until you exit the session, we can exit with Control D or Control C. For example, this type, this one list name, node. It returns undefined because this is a statement in JavaScript is not an expression. Don't let that confuse you. If you type five, strict equal 5, it brings us to grow because this is a Boolean expedition. The ripple width, it's dissolved for us. Let's try with a function. Now. Let's see. Let's call our function, is returning our value. So this activated the multi-line model editor, matlab editor. Our code is not done yet, so it will go into a multi-line mode for you to type Marge man who finishes graded function definition, you will get out of this multi-line mode. But this is actually saw limited node is bringing us that editors feature. This will enter the editor mode. We can type however many lines we want. Harmony lines, V1, V1. For example, let's try this and to get out of this Control D. And we can't see my function. We can use stepped autocomplete 36. And my other fun, another function, 36. Yes, we can access. These functions are side of the dot editors. That editor command is, is rippled spatial command. There are a few other special commands. Uv can't see these with that help. For example, that break that clear dark color like alias for doc brake. And that load and save commands can be used to generate our news external naught scripts inside your ripple. This can be a great time-saver. Okay, let's move on with turbine auto-completion next. 7. Tab and underscore: The cool thing about the ripple is it's, it's interactive. As you write your code, if you press the Tab key, the ripple will try to auto complete. But you wrote to match your variable, you already defined what a predefined one. Also we can use like a double tab. We can press the Tab key device can be used to see a list of possible things you can type from whatever partially type string you have. Auto-completion discoverability works in evaluating the re-position. For example, we can just dab that double-tap. We can't see the or we can just double tap on an empty line and we can see everything that is globally available in NADH. This is a very big list. In this list, you can't see all the common globals in the JavaScript language itself, which you are probably familiar with like array, numbers, string object classes, built-in libraries like met, JSON, and some other top-level functions. This list also has the globals that are available in the node runtime itself. If you have, these are truly globals in not like the buffer class. And the process object. The various functions to sit and clear timers like setTimeout, setInterval, set immediate. These are the powerful libraries that you get out of the box. But to use these inside of a project, you need to require these modules first to be able to use them. Let's try, for example. Other stuff like numbers. Tap, double-tap. We can see everything available inside the number class properties and methods. Also we can see like array that double-tap. We can see everything also inside the array class. For the underscore, one of the useful ripples features that you can't see. You can't see is the underscore variable. Here, underscores variable. It stores the value of the last successfully evaluated the expression, for example, like we are using Math.random. And we can store this value like none kills, like underscore. And when we type num, this will be available. It automatically stores the last value. Okay? Now we will learn how to execute JavaScript code. 8. Execute javascript code: After we learned about not rapid enlightenment, is time to execute some JavaScript code. For this we will create, we will build our first web server. Create a file named app.js containing the following contents. Just copy these into the text editors, whatever you want to use. I'm using Visual Studio Code as you can see. And here we are requiring the HTTP. We are setting the proton hostname and we are creating the HTTP server with this command. And we are sitting some status code like to a 100 status codes. We are setting the header for our content type text plain and we are sending helloworld message to listen VR using that listen event and servers running it HTTP, host name and port. As you can see now, we paste it to go down to run the code. We will just need to do not app.js. It will give us the message server running it, HTTP and port 3000. Let's go that and it's giving us it helloworld message. We can see here in the Network tab all the things we set for the HTTP server status code 200, OK, then content type text plain, same and message hello world. So that's it. So easy to execute the HTTP server, we just type node and the file we want to execute. See you in the next video. 9. Browser vs Node: Script has existed since 1995 and has become the dominant language for web development before we were using JavaScript mainly for client-side scripting inside secret texts executing in web browsers. Now we will compare JavaScript in the browser and JavaScript V8. Note. When width browser, we can build interactive apps for the web. With not, we can build server-side EPS and scripts. In browser, we can have access to the DOM and window object and its related objects with NADH week and we don't have any agree, we don't have any DOM. And we can access to the global object instead of window. Let's try this out window. We can see the window here. If I type global eschewing, ask a level, this is a window again. Let's try with now. Let's try to access window is giving us an adage. If you tried to access global, it's giving us the global object. We can see like we have clear interval, CALEA time-out set interval. These are all coming from the global object. And if it tried to access document, it will give us the HTML DOM. Here. Document is giving us an average. Here we can access through the process. Process in the CLI gives information about the environment we are using. In browser, we can use optional modules like ES6 modules, and we can reference variables in other files freely. In NADH we have required modules, CommonJS modules plus atmospheric modules like it's experimental, but we can use it my script on CommonJS modules. Here. We need to use required keyword and module.exports to export. Also, we cannot access file system in the browser width not we can access to the file system. Both of our abode of them are asynchronous. And in browser we have some browser APIs. In not, we don't have any browser-based APIs. So what is the one difference when writing JavaScript for NodeJS over the browser? No need to account for incompatibilities between browser JavaScript engines. So this means like normal fragmentation. Before whammy tried to use any, something like fetch, Flexbox, anything we were checking like, is this compatible with h, is this compatible with Chrome, Safari, Opera? But with note, these are versioned. We are just downloading whatever version we want to use. And it's always working. No more polyphenols. And if we want to include some libraries in the browser, we need to use script tags. With naught. We need to include them through NPM Node Package Manager or npm install to use. Okay, now, we can continue. 10. What Node is NOT: In this video, we will learn what is NodeJS not nudges is not a very frameworks not going to replace Rails is not going to replace Django is severely low-level network communication we are talking about here that are libraries that people have written that sit on top of note to be a web framework like express JS, but not at its most basic level. It's not that and not the diapers around JavaScript V8 runtime like V8 runtime are not written in JavaScript, they are written in C plus plus. Node is also not a multithreaded application. Let me write out applications with not rewrite them as if we are dealing with a single threaded server with a Kobe concept, we will learn about event loops run hand is not for JavaScript beginners is severely low-level. Okay, let's move on. 11. Client Server Communication: This video, we will learn more about NodeJS. Nodejs is an event based non-blocking, asynchronous I O runtime that uses Google's V8 JavaScript engine and live UV library. So what is non-blocking asynchronous IO event-based runtime libc library. We don't know about this, so we will learn more about these in the next couple of videos. We know what is the runtime. Runtime takes our code and converts into a native machine code. And for this, we are using Google's VHF Script Engine written in C plus plus. Why Ryan Dahl chose JavaScript. He said javascript has no concept of threads and its model of concurrency is completely based around events. So we need to learn more about what is threat and what is event, right? And yet it will set co-founder of StackOverflow. Any application that can be written in JavaScript will eventually be written in JavaScript. Now, we should learn more about how do browsers and servers connect with each other. If you want to learn more about this, you can read it in Mozilla ducks. So in this model, the client refers to the user's device or program that is making a case for data. A client can be a browser or replication running on a user's laptop, smartphone, or tablet. The server is the device or programming that network that waits for incoming requests and sends back data. This might be an in-house server, a rented server, data datacenter, or a Cloud server. The server is a specialized computer connected to a network that provides our serves up resources. So the browser initiates, dedicates to the server and renders website files. The server stores website files and sends them to the web browser upon request. So the browser and server communicate with one another using the Internet Protocol, HTTP or Hypertext Transfer Protocol, which allows for data transfer. As you can see, we are searching something on Google. We are making their case to the server. That server is responding to the client by loading a page or sending data, it can get the data from database. The arena of this, this is the basic level of client-server relationship. Now, we will go deeper into client-server relationship. C, U dash. 12. Threads: In the previous video, we talked about client-server relationship. We are making a catechist server is giving me whatever I want. Dating this is realistic. Imagine is Amazon Prime Day. We will have a lot of customers, millions of customers on our website at the same time and they are trying to purchase something. How will we handle saw many requests at the same time. For example, I am trying to get to my cart and serverless taking my information and it's asking to the database. Okay. We are waiting for the database. Server is waiting for a database, but at the same time, other users are coming and they're also trying to get to their cart because they want to purchase something from Amazon. So while we are waiting here at the users would wait for other users requests to be handled first. So it can take a lot of time because it takes time to get data from the database. So this is good news. There's a thing as threads. Threads are a way for systems to run multiple operations concurrently. So every request would open a new threat. For example, I'm opening a threat for the server. This usage and user is opening a new thread. This user is opening and nutrients. So we're opening multiple threads. And every thread will have it all required to run the same code to completion. Let's make an example. Here. We have run waiters and waitresses serving to one customer. But when the food and when the demand for food increases thinks would go crazy, people would have to wait till all orders were delivered. Evey, to solve this problem, would be to employ more people to serve food, right? This way, more customers would be served at once. So for every customer, we are hiring a new waiter. Now we hired more people to serve our customers. And each rater is handling only one customer. So each thread is a new employee and the browsers are hungry customers. So bleeding is this good? Like for every customer, we have a new threats, new waiters. The system has a downside. It would get to a point like van, there is a lot of requests and starting up new threats would consume a whole lot of memory and system resources. Also, in our example, example, employing modern more people to serve food would cost more money and space. Of course, some innovator. We cannot employ some innovator. But it's also a good thing that immediately the server response to the browser and the connection is closed and all the resources, memory, etc, retrieved. So there are good size I'm bedsides. Yes. We need to use Edit of memory. But good thing that it's closing in like it's given me my information. And then at the benefit of the system that it excels at CPU intensive applications, CPU-intensive operations required a lot of logic and take more time to compute. Since every request is handled by a new threat. It takes serious work of the main threat, therefore, making the system fester and able to perform important computations. So it's quite efficient because each operation executes code of the main thread. But could things get better to eating? Okay, Let's think PHP, the server in case the file from the file system. Php is multi-threaded server, like in our example, elevator has different client, different customers. Php is also behaving same. Then the server waits until the system open sundries the file. The server is, returns the data to the client. The server handles the next request. So it's important to understand that PHP 13 to file for us directly. Php will tell the file system to read the file and return the contents. The file system is a program used to store and retrieve data on a computer so it can take time to get the data from the file system. The point is PHP just sits there doing nothing till the file system is done, is just waiting. Okay, give me my file. And then PHP collects the content and sends the contents to the browser. But about NodeJS in not, we are again requesting a file from the file system. But this time the server handles the next stroke. Is it not waiting? Bandwidth system opens and reads the file. The server will return the data to the client. So in not while the file system is reading the file, node uses idle time to handle other requests ran. The file system is done. It's smart enough to tell node to come to take the resource and Sandy to the browser. The node will handle multiple requests, but it will not wait for the server to respond. So the single thread will not be blocked for a single client. I said blocked for a single client. What is blocking? What is non-blocking? Blocking means like any JavaScript code that takes too long to return control to the event loop will block the execution of any JavaScript code in the page. Even it can block the UI thread and the user cannot click it and scroll the page and so on. For example, here. Let's write like alert. Hello. Okay, I'm trying to, I'm trying to change. I cannot scroll integral. So this is blocking code. Imagine in your browser, your website blacks that single thread for say, two seconds. And the user hierarchy, I couldn't scroll up and down during this two seconds. In nought, if an incoming HTTP connection to your web server was handled synchronously rather than asynchronously, that will block the single threat. We have only single thread, so we cannot operate like this because it will just block. And your whole web server cannot handle the, any other connections via the synchronous operation is active. That's really bad, so bad. But the Batman blacking almost all IO primitives in JavaScript and non-blocking disk and network decrease file system operations and so on. Being bulking is the exception. And this is via JavaScript, is based so much on callbacks and more recently on promises and async await. So to not to block, we are using callbacks, promises and async await, also knots event loop. In the next video, we will learn more about this. See you. 13. Event Loop: And the last video, I finished with promises and async await. If you don't know about these concepts, you can check this in Mozilla, developer dot Now, we can continue on learning asynchronous programming. Callbacks, event loop, movie, asynchronous IO worker threads, but lacking event queue everything. Event loop. It's a part of the JavaScript engine. That's all the magic behind the scenes. Unlike other languages that required a neat thread or process for every single case, NodeJS takes all the requests and then delegates most of the work to other system markers is taking our request is going to the event loop, is registering a callback and is delegating to the system workers. They are doing the intensive operation. It can be in the file system database computation than Van de operation complete. It triggers callback. And this is single threat. So our event loop is not busy, is delegating to the workers. Here we can also see event loop blocking operation. Then we are seeing worker threads. This time we are seeing also EBV. What is Libby when they re library that handles this work effectively with help from the OS kernel ran the big grand workers are done doing their work. They emit events. Yes, they execute callback. And they emit events to NodeJS, callbacks registered on that event. So the beauty is providing us a synchronous non-blocking IO library is using a system kernel and it has multiple threads. So analogies is single threaded reset, but behind the scenes, library has multithreaded. Thanks to Libya VBR handling these. So amino operations saw among educators at the same time. So I said, we are registering a callback than we are delegating to the worker threads. What is a callback? They are basically functions paste into other functions as arguments and are called Van. Certain conditions occur. Well, so it's also important to know that everything in JavaScript runs parallelly except our code. Yes, our code executes wanting at a time when at that workers are doing their jobs concurrently. Let's make an example. A great king had many servants, image and I King. Maybe you can be a king like you have thousands of other servants. And you are making a list that you want your servant to do than 70s taking your list. And it's a his delegating work to all other servants. Ran one is done, he takes his result to the king. The king is always busy making other lists, like in our event loop. Event loop is always busy. Our king is always making this. And while the servants were working, king is also busy like making lists. So he collects his result and gives him in other work to do. The point is, the king does one thing at a time. Even if a lot of things are running in parallel. In this analogy, the king is R code and the servants and NodeJS background workers. The king is here, background worker, sermons, such worker threads. Everything is happening parallel except are called. Nodejs is extremely faster than multithreaded systems. Yes, even with Him, single threat, how is this possible behave on the one thread, but it's faster than multithreaded systems. This is because programs usually don't only consist of turn, they don't own knee in need. Numeric arithmetic and logic computations that take much time. They are done. They don't only need CPU-intensive work. In fact, a lot of times they merely write something to the file system, to a network requests or exist the console or an external device. Note excels in situations like this. Pan it experiences damn, it quickly delegates the work to someone else and take other incoming requests. So our single thread is always open. So we shouldn't use, not for CPU intensive operations, they overload the main threat we have on the one thread we shouldn't use for CPU intensive operation by using single threaded systems is ideal to avoid such operations. So the main thread can do other things. This process constantly checks the call stack. If the call stack is empty. If and if it is monitors whether there is an event and the callback queue waiting to be invoked. The event loop is what allows NodeJS to perform non-blocking IO operation, even though JavaScript is single threaded by offloading operations to the system, kernel journals are core of toys. When one of these operations completes the kernel task, no JS that the appropriate callback may be added to the pole Q to eventually be executed. So JavaScript is a single thread, so is not. The event loop, is basically a program that waits for events and dispatches them when they happen with the help of Callback functions. I hope you understood. See you in another video. 14. What can you do with Node?: Okay, it's time to learn what we can build with NodeJS. We can build a wide variety of production 3D applications with NodeJS. These can range from traditional lightweight high traffic chat applications to command line tools and web servers. Nodejs was designed from the ground up to handle a high number of concurrent requests. We can create manipulate files on the file system. We can write shell scripts for file manipulation on network access. We can create interactive command line interfaces. For example, ES lint and your man uses Node.JS. You Amanda web scaffolding tool for modern web apps. After that, we can build web servers like HTTP and express. Express is a web framework to build a web servers. And HTTP comes bundled with NodeJS itself to create web servers. And we can be a powerful APIs backend interfaces for stake apps. Also, we can create ed servers, advertisement server. I think Ed service should be the fastest servers because from an advertiser's point of view, if I can load the Eds before all the contents of the page is loaded, I make h to visitor and enter. That is if my IDS lot slower, the visitor might navigate to somewhere else. So add servers really need to be fast and thus not should be used. Also, we can create WebSockets server like a chat servers value or you have your browser, lots of browsers connecting to the server and there is a chat going on. So you are sending messages back and forth between the client and the server. And the second stays open. So a chat application is good for no dips. The best examples of real time exchange of data are IM, applications with that for exchanging texts, voice calls or video calls. The asynchronous nature of Node.js runtime makes it suitable for building communication apps. Also, we could do file upload client van, you think about applauding, beak large files. You want to be able to do it innovate is not blocking. Yes, It shouldn't people liking if you are loading peak large files. So you can do more than one file at a time and maybe even start processing the file is you get the first five pieces of it. Also, we can create this step applications with subsets of node electron. Electron. Let's not just developers create this stuff GUI applications and is the foundation on which many popular applications have been built, including the atom and Visual Studio Code editors also get Curriculum postmen, it should end this slag client. We can create CDN. Cdn is a network of computers. We can create shareable libraries like open source libraries, Node.JS environment also for MPM legislated you can use to share your own NodeJS library. For example, NPN express comes with NPM registry. It's built on npm. We can install it through NPM. And NodeJS is popular on Internet of Things. Devices, IoT devices. It's architecture is especially well suited to micro-service development and often helps form the server side of Fullstack applications. Many Internet of Things and real-time applications that are written in JavaScript and rely on NodeJS to run either on the server or through microcontrollers and system on a chip platforms such as package.json, TESL, package.json, and open-source javascript microcontroller. You can program and debug wireless D. This is built with NodeJS, also pestle, pestle tool. Also we can't see that it's using Node.JS. And Johnny Five. This is also built with NodeJS. It's like robotics platform. We have with NodeJS. Also microservices. Microservices fit them NodeJS model of event programming efficiently at the core, bought feature a system for building highly scalable apps. We can create a databases like MongoDB, MySQL, Postgres, and redis. Also we can use for machine learning libraries and muddles and tooling like webpack, gulp, grant, build an automation, etc. Also we can create serverless API backends and Cloud Functions like AWS Lambda Azure, and Google Cloud. As you can see, we can create pretty much anything because node is on everything. Now. We can look at applications that are built with NodeJS. For example, CLI tools such as picks up that RAM. This is for Azure CLI and Azure Functions core tools, command line tool. These are all built with NodeJS. Actually. Now we can't see back-end servers and API services such as expressed and nest JS. Nodejs frame for a framework for building efficient, reliable, and scalable server-side applications. We saw that we can create slag using electron IoT libraries such as Johnny Five package AS and TESL, and plug-ins for SketchUp and Adobe XD. Also native mobile development with native script, even more mobile development we can make with NodeJS. Okay, see you later. 15. Advantages of Node: This video describes the main benefits of using Node.JS and men to use it. Advantages of NodeJS. Firstly, it's fast because it's mostly see called C plus plus. It's simple to use is JavaScript, one language every rash. It allows us to build entire applications and to end in one language is JavaScript. Even if you have never used JavaScript as a primary programming language, it might be the right choice for writing robust modular applications. Javascript also offer some unique advantages. For example, because browsers use JavaScript, you can use Node.JS to share logic like form validation rules between the browser and the server. This is why many developers like node, because it's lightweight and you can write your front-end and back-end in the same language and shared libraries reduce called the right times and takes tech adoption efforts. Javascript has become more relevant with the rise of single-page applications, SPAs and supports the white layer and widely used JavaScript Object Notation, JSON data exchange format. Many NoSQL database technologies such as CouchDB and MongoDB also use JavaScript and JSON as a format for queries and schemas. Nodejs uses the same language and technologies that many modern services and frameworks use. So one language means less syntax to keeping your head, less APIs and tools to work with and less mistakes overall. Bundling, which means better integrations between your front-end code and your back-end code. You can actually share code between these two sides. For example, you can reuse your front-end UI components called to render server-side HTML. The advantage of this scripting technique is that clients do not need to deal with slow loading times and high CPU usage. For the same effect, developers can employ static web pages, but my website content would be in PTEN loss now far less engaging and interactive. And it's fest to deploy. Another reason is scalability. From client-side development to full-stack development. From simple webpages to largest scaled applications to windows make desktop apps with electron and hardware embedded systems. It's so much scalable and it's server-side scripting empowers developers to dismiss the often overloaded presence of browser plugins and technology by simply relying solely on the web server. No more browser incompatibilities or poly fills. And it's source community. Nowadays is open source technologies supported by the Open JSON Foundation, a massive, active open source community and contributors continuously work to improve and optimize the technology. A top-level Community Committee has authority over community outreach efforts. The community has already built more than a million modules and libraries for NodeJS and publish them onto node package manager. Npm. Developers can easily download and integrate these modules into their existing projects. Are curious which companies are using NodeJS? Node.js is one of the most widely used technologies by many companies, startups and government organizations. These include major enterprises like Netflix, thread law, Walmart, we were eBay and nasa. For example, we are seeing eBay here. It's an e-commerce application. So e-commerce platforms handle simultaneous recurs in real-time and its scale, NodeJS solves this problem with it's non-blocking IO model. In fact, one of the two primary requirements that throw eBay technologies while the capability to handle io band operations. Also, netflix is a streaming application. Netflix is perhaps the most popular streaming application that runs on NodeJS. Beyond the prior need to use the same programming language for both the server and the client sites. Nudges has an efficient model for handling streams, which are perhaps the best feature of the runtime. Also, we are seeing collaborative tools like Trello. Collaborative tools require real-time transmission. 300 is the most popular collaborative app built using Node.JS more so it's a single page application, SPA. And at the type of update, NodeJS is particularly efficient in handling. Here you can find more information if you want to explore why these companies transitioned into Node.JS, you can see how enterprise companies using node. And this is a general introduction about node like reasons and benefits. Seven famous apps built on Node.JS. This is for Netflix. Developers working on the website had to be really gives a, you can't check all of these links if you want. Okay. See you later. 16. What Node Brings: Okay, in this video we will learn about NodeJS. What it brings to the table, not comes with built-in modules providing easy-to-use asynchronous APIs. Let's talk about it and the reasons why developers are picking NodeJS over Menander options when it comes to creating services for their backends. First of all, it comes with native modules, bit thin, built-in modules like FAS, HTTP, crypto, zip. You can see all these built-in modules in the documentation file system. For example, crypto File System. And these are like feature-rich modules that makes the grids and great platform for hosting and managing servers. These modules of her features like reading and writing files thanks to FS module, file system module began consume data over the network with HTTP and HTTPS. We can even compress and encrypt data. Thanks for crypto. So you don't need to install these modules. They come natively packaged with node. If not, packages, built-in modules run not enough for you. You can build high performing packages using C plus plus. Notice first-class support for C plus plus add-ons creating dynamically linked shared objects that you can use directly with. Not of course, if you want to build with JavaScript, you can also build with JavaScript, C plus plus and java script add-ons. We can build. And it comes with debugger than at other utilities that provide the X-ray PIs to work with datatypes. Note also ships with a powerful debugger. N has some other handy genetic utilities that enhance the JavaScript language and provide x-ray APIs, for example, to create timers, work with datatypes and process arrays and objects. Even if you don't want to host your backend servers in not having the powerful built-in features and the East for edX MOOC makes not a great platform for tools to rapid other applications and enhance your workflow. And it comes with npm. Npm is the best thing I think a package manager and the dependency manager, the package management system, npm, provides the largest free reusable code. The libraries in MPM provide a large set of utilities to NodeJS applications. You can make feature-rich, not a Node application just by using code that's freely available on NPM. Npm is a reliable package manager with which comes with a simple CLI, npm command. You can use the npm in your device. Like this. We can see we can use npm install, npm install anything like npm install express npm test for testing MPM run something we can run any program. Mpm help and PM have NPM. Yeah, you can't see the CLI here. When you type in the terminal. The npm command makes it really easy to install third-party packages share your own code and you use your own code. In addition, the NPM registry where the packages get Hoss the test. So common options by summing, I mean hundreds of thousands of options of free tools that you can just install and use on your not servers. The other big thing about nudges is that it comes with a reliable module dependency manager. This is different than NPM. This module dependency manager is also another thing that we didn't have in JavaScript world. Knows node's module dependency manager has been available since not valid released, and it opened the door to so much flexibility in how we call javascript is widely used, even for JavaScript that gets you executed in the browser because npm has many tools to bleach to get between modules, did an inode, and what browser can work with today. We can't see the modules here in the documentation. We can use CommonJS modules and Achmat Script modules, ES6 modules, CommonJS modules like we need to use required keyword to require a package and to export the Kenya's exports that ADR like anything or module.exports. You can read it here. And it musket modules we need to use like import. This is still experimental as you can see. So I think it's better to use CommonJS modules. This is stable, as you can see. Okay, now I said so good things about Node.JS. You may be thinking what can be the drawbacks of NodeJS, right? I shouldn't use Node.JS. We will learn about this next. 17. Drawbacks: That is not perfect app platform. Our technology note has also drawbacks. First of all, it has a very different way of thinking. For example, not asynchronous, non-blocking nature is just a completely different model of thinking and reasoning about code. If you have never done it before, It's going to feel weird at first unit time to get your head wrapped around this motherland to get usely it. And NodeJS uses callbacks. Sometimes callbacks become so nested that they are near impossible to manage. This is known as the callback hell. And developers hate this situation. And more efficient option is to use promises. Promises are used to panned code execution and unnecessary. And other option is picking good options. Npm has a big package registry. That means every single tin Unit 2 Do you have many options to pick from? And some people hate it. You need to consultant and constantly researched these options and make a mental effort to pick the better ones. These options usually have big differences and you might end up spanning edit of time, researching them. You can use a lot of packages. And it has small packages. Right? Node is named NADH because smaller code is actually y naught is named know in nope, we build simple, small single-process building blocks, nodes that can be organized with good networking protocols to help them communicate with each other and scale up to build large distributed programs. And an NPM can have security risks. If you know about left pet, you should know about this, how one programmer broke the Internet by deleting a tiny piece of code. So you should be really careful what you are downloading. You should check weekly downloads. Carriage are the test passing. Like version. And PM has a big registry and when you download the event and one package, for example, Express, you can get a lot of dependencies because npm has its own dependencies too. So you should keep this in mind. Also in the aerobic is NodeJS is designed for lightweight performance. For IO operations, it can run into trouble if Dave, he uses heavy CPU resources for this node created worker, worker threads in 2018. So worker threads have mitigate this problem to an extent by introducing multi-threading to NodeJS. Worker allows for running CPU-intensive coordinate parallel thread different from the main thread. So actually this is not the aerobic, just for CPU intensive tasks, you can use worker threads. And the run is. Another challenge for NodeJS is the instability for its API, which changes often as a result of the lack of backward compatibility for many of these changes, developers usually had to rewrite parts of the record which with each update. Okay. 18. Interview Questions: Area up for a challenge. I know you are ready. If you are watching this video, you must be ready. Or maybe you are not ready either. No, but we are starting. In this video, we will learn some bonds interview questions. I hope you will think about two questions and you will try to answer. You can just pause the video and try to answer the question. You can't say it out loud or like you can just think about the question. Okay, let's start it. One. In a Node.JS environment who executes the JavaScript code that you write. Pulse, a VM like V8 or chakra. Guess we learnt it. No dessert. I put around media and V8 JavaScript engine. In which programming languages can you use to create NodeJS add-ons, pulse, C plus plus and java script. Yes, we can create our add-ons with C plus plus and java script. We talked about this way is not JS single-threaded. Pause here. Nodejs is single threaded because of it's a single architecture. By doing isn't processing on a single thread under typical web loads, more performance and scalability can be achieved. Instead of the typical credit based implementation. For Hobbes, NodeJS most frequently used. Okay? We can use NodeJS in many ways. We can create real-time chat applications. We can use for Internet of Things, imbedded devices. We can create complex SBA single-page applications. We can create a real-time collaboration tools like Trello. We can create streaming applications like Netflix, and we can use for microservices architecture. I hope you are doing great. I know you are doing good. A, so let's go on. What is npm? Positive. Okay? Npm stands one node package manager responsible for managing all the packages and modules. One NodeJS provides online repositories for NodeJS packages, modules which are searchable on W, W dot NPM Also, it provides a command line utility to install NodeJS packages and also manages NodeJS versions and dependencies. Yes, we learned how to use the command line. Six. What is a callback in Node.JS? Positive. A callback function is called after a given task. It allows other code to be run in the meantime and prevents any bullock when we are using callback function to use asynchronous code. Being an asynchronous platform, NodeJS heavily relies on callbacks. All APIs of node are written to support callbacks. Seven, what is i, o, input-output. Positive. The term IO is used to describe any program, operation or device that transfers data to or from a medium and tour from another medium. Every transfer is an output from one medium and then input into another. The medium can be a physical device network or files within a system. Eight, what is the command used to import external libraries? Comment, okay, think about it. The required command is used for importing external libraries like const http. Require http. We are requiring HTTP module with required keywords and keyword. This will load the HTTP library and the single exported object to the HTTP variable. Nine. What are the two types of API functions in Node.js? We have a synchronous non-blocking function, sends synchronous blocking functions. So we have two types of API functions in Node.JS. This is our last question. What is liberty? Liberty is a multi-pronged platform support liability with a focus on asynchronous IO. It was primarily developed for use by NodeJS, but it's also used by Louis Julia, PY, UV and others. I just gave a little more information here. Some of the features of liberal VR. Full featured event loop back by Apple, qui que Josep event ports, asynchronous see TCP and UDP sockets. Asynchronous file answers in a file system operations, child processes, file system events. Okay. I hope you did great. You can share your results. In the chat. We come along. 19. Review and Closing: Here are some additional resources and these are the links. If you want to learn more about naught, I put some books, some GitHub links and websites. You can check them out here. You will just click and it will take you to the webpage. I hope you will check them out. They are really good resources. And if you have any questions or any feedback, drop it in the chat. Thank you for taking the time to go through this course. I hope you gained a lot from it. Please reach out to me on social media and media on TV. You can't say hi Anthony, value total of the course. I would love to hear from you. And you can follow me on Skillshare. In this course, we learnt it. Nodejs is a runtime that can run JavaScript applications and code outside of a browser. We also learned how NodeJS works and via wind node is a good choice for building and running, running JavaScript applications. These can range from building application servers, running real-time applications on Internet of Things, emitted devices. I hope you enjoyed the course. See you next time.