Fyresite Fyresite Digital Marketing Fyresite® (888) 221-6509 info@fyresite.com 2009 1201 E Jefferson St #6 Phoenix AZ 85034 Arizona California

What is Node.js?

Node.js is a runtime environment that executes a Javascript program. Node.js was created as a Javascript extension to running programs from just on a browser to on your machine as a standalone application.

The Composition of Node.js

Node.js increased the number of uses for JavaScript to more than just being a language to make websites interactive. Thanks to Node.js, you can now use Javascript to do things other languages can’t, such as Python.

Chrome’s V8 Javascript Engine

Node.js runs on Chrome’s V8 Javascript engine, which takes the code and converts it into a faster low-level code that computers don’t need to interpret. This eliminates process time and increases speed. The Chrome V8 engine was written in C++ and implements ECMAScript, which was created to standardize Javascript. It makes writing your own C++ code a simple process and allows you to add more features.

There are more Javascript runtime engine’s than just the Chrome V8.

Non-blocking Input/Output

The other great benefit of Node.js is that it uses an input/output model that is non-blocking and instead, event driven. Input/output means anything from reading and writing files to making HTTP requests.

A blocking input/output model makes multi-tasks inefficient because it is a single-threaded event loop. This means that if you were to request data for two users to be printed on the screen, it would first initiate the request for the first user and then initiate the request for second user once the first user’s data is printed on the screen. A non-blocking I/O eliminates the need to wait for the first user’s data to be printed and instead takes and runs both requests at the same time, making it perfect for multi-tasks.

Node.js Package Ecosystem

Node.js also has the largest ecosystem of open source libraries, known as the Node.js package ecosystem (npm). You can find solutions to most of your problems that will make app development faster and more efficient.

Require

Require is a function that does three things. It loads modules with Node.js and HTTP from the Node.js API, it installs libraries from npm and it allows you to set requirements for only your own files and to modularize the project.

Node Modules

Node modules are blocks of code that don’t impact other code unless written to and can be reused. You are able to use them in various applications and you can write your own. There are also built-in modules that you can use without any installation.

Events

There are system and custom events in Node.js. System events are written in C++, which can be found in the libuv library and custom events are written in Javascript.