Intro to Node.js

Noble Desktop

Navigate: Right/Left Arrows (or Swipe Left/Right)
Zoom Out: Press Esc (or Pinch)

We’re Going To Discuss

  1. What is Node.js?
  2. History of Web Development:
    Google V8 Engine, Google Chrome, & Ryan Dahl
  3. npm: node package manager
  4. What is Node good for (and not good for)?
  5. Model View Controller
  6. JavaScript Template Engine
  7. Express.js & MongoDB
  8. Transition to the MERN Stack
  9. Why Learn with Noble Desktop

What is Node.js?

Before we talk about what Node.js is, we need to exam how JavaScript works on the browser/client side.

Almost all modern browsers have JavaScript engined baked into the browser. This is why we can run JavaScript in the browser.

How do we run JavaScript without a browser?

In 2008, Google released their Chrome web browser using the Google V8 engine.

In 2009, Ryan Dahl used the Google V8 Engine to run JavaScript without using a browser.

This gave birth to Node.js. It allows us to create a server, read files, send messages, access a database, and much more.

How Does Node.js work?

Traditionally, languages such as PHP, Ruby, and many similar programming languages require a lot of resources to handle multiple requests.

Think of a restaurant hiring multiple workers when it gets very busy. The only problem is what to do with the extra workers when the restaurant is slow.

How Does Node.js work? (continued)

On the other hand, Node.js works completely opposite.

It doesn’t hire additional workers to meet the demand, but it has a task manager that distribute the tasks smartly.

This way, you don’t need to hire additional workers and also get the job down efficiently.

Node.js, Browser API, C/C++ and LIBUV

JavaScript, by itself, is a synchronous language.

But when JavaScript is run on the browser or on the server, it becomes an asynchronous language.

What is an API?

Application Programming Interface

Think of the API as a smoothie shop menu. The drink menu shows a collection of drinks you can order and the ingredients. You can order it and customize it however you see fit.

An example of an API is Airbnb: You browse a list of homes you want to stay in for your vacation. You can pick a dog-friendly home with a parking space. An API could be a list of features or a pile of data.

What is browser API & Node API?

The browser API allows coder to manipulate the DOM.

Think of following or unfollowing a friend on Instagram.
It shows you that you have 1 follower, and if you don’t have any it will show you have 0 followers.

The Node API allows programmers to start a server, read files, access databases, password hashing, and more.

How does JavaScript know how to do all this?

Under the hood, when the Google V8 engine reads the JavaScript files, and it sees them trying to read a file, it will access the LIBUV library and use the read file function.

Which is why Node.js is allowed to start a server.

LIBUV is written in C and C++.

What is Node Good For?

  1. Web Server
  2. Supports tens of thousands of concurrent requests/tasks
  3. Inputting and outputting real time data
  4. Building API
  5. And many more...

What is Node NOT Good For?

  1. Computing data. This is why Python is used for data science.
  2. Heavy Computation Applications

Node Package Manager

  • The popularity of Node.js sky rocked because of the Node Package Manager (NPM).
  • NPM, is a global registry that many developers across the world collaborate to create tools we use.
  • It has a huge community constantly working for free to update the packages and modules.
  • Think of a buffet except a buffet of pre-built packages and modules that we can use. So we can focus on building applications.

Express.js

									

											const express = require('express')
											const app = express()
											const port = 3000

											app.get('/', (req, res) => {
												res.send('Hello World!')
											})

											app.listen(port, () => {
												console.log(`Example app listening on port ${port}`)
											})
								
							

MongoDB

No SQL database, it uses the document object model

									

											var MongoClient = require('mongodb').MongoClient;
											var url = "mongodb://localhost:27017/mydb";

											MongoClient.connect(url, function(err, db) {
												if (err) throw err;
												console.log("Database created!");
												db.close();
											});
									
							

Why Attend Noble Desktop?

  • Smaller class sizes
  • 1-on-1 attention
  • Small group learning
  • Compacted learning
  • Resume review
  • Interview prep

Learn More

JavaScript Certificate

Full-Stack Certificate

Software Engineering Certificate

Noble Desktop Copyright Noble Desktop