It's All About NodeJS
Tags: javascript, node, webdev, beginners
Published: 2020-09-13 17:47:26

>_"One of the main reasons **why NodeJS is popular** is because it uses the JavaScript as their main application to create new application. Plus, JavaScript is the developers first choice to develop new web applications. The new and robust framework is introduced to many new developers to create the wow factor. **Want to know What's that WOW factor is then this article is for you…**"_

![NodeJS](https://dev-to-uploads.s3.amazonaws.com/i/q4zykrwxu2ipdtxujac0.jpg)

#**History of NodeJS**

* **Writtern And Introduced By** : Ryan Dahl in 2009.

* **Official Website** : https://nodejs.org

* **Github** : https://github.com/nodejs/node

* **Download Nodejs** : https://nodejs.org/en/download/

![Download nodejs](https://dev-to-uploads.s3.amazonaws.com/i/b9xbx85go0gv1gq3bbpt.png)


# **What Exactly is NodeJS?**



![what is nodejs?](https://dev-to-uploads.s3.amazonaws.com/i/prxof67nulwongajm79t.jpg)

> NodeJS = Runtime Environment + JavaScript Library

* Node.js is an open-source **server side runtime environment built on Chrome's V8 JavaScript engine**. It provides an event driven, non-blocking (asynchronous) I/O and cross-platform runtime environment for building highly scalable server-side application using JavaScript.

* Node.js is **open source, completely free,** and used by thousands of developers around the world.

* For NodeJS, **you should have a basic understanding of JavaScript**. As you going to develop web-based applications using Node.js, it will be good if you have some understanding of other web technologies such as HTML, CSS & basic JavaSscript.

> "It simply means that you can use JavaScript for Backend development".

# **Why NodeJS?**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/49d9p49nzxe6cx6oidjy.png)

### **Lets deep dive into some awesome feature of NodeJS :**

##1. NON-BLOCKING :

Non blocking means that **while we are waiting for a response for something outside of our execution chain** e.g. loading some data, reading from a database or polling a remote service, **we continue executing the next tasks in the stack**. This concept is revolutionary and make NodeJS extremely fast and efficient.

##2. SINGLE THREADED

NodeJS is a **single threaded language which in background uses multiple threads to execute asynchronous code**. It is non-blocking which means that all functions or callbacks are delegated to the event loop and they are ( or can be ) executed by different threads. That is handled by NodeJS run-time.

##3. ASYNCHRONOUS AND EVENT DRIVEN

All APIs of Node.js library are asynchronous, that is, non-blocking. It essentially means a **Node.js based server never waits for an API to return data**. The server moves to the next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response from the previous API call.

> **What is the difference between Synchronous and Asynchronous?**

> **Synchronous** : Execute something synchronously, you wait for it to finish before moving on to another task.

> **Asynchronous**: Ask for something to happen, get notified when it does. Do other stuff in the meantime.

![Async NOdejs](https://dev-to-uploads.s3.amazonaws.com/i/pwumhqs6ogghvq89us71.png)

**The server can respond to multiple requests at a time.** It won't stop or block any API request and will respond to all when the response is ready to send accordingly.

Every thing is event based. Such kind of approach will fire callback (functions most of the time) as the event occur (state changes). An event based system is always be in circular loop to execute it's responsibilities

##4. Node Package Manager - NPM

* **npm** is the world's **largest Software Registry**.

* The registry contains **over 700,000 code packages**.

* Open-source developers use npm to share software.

* Many organizations also use npm to **manage private development**.

* npm is **free to use**.



![module counts](https://dev-to-uploads.s3.amazonaws.com/i/186gec5vtrzcts4pctjx.png)

You can download all npm public software packages without any registration or login.
```
C:\>npm install <package>
```

* All npm packages are defined in files called **package.json**.

![package.json](https://dev-to-uploads.s3.amazonaws.com/i/7963wvmnoaegx2iazp92.png)

## 5. No Buffering
Node.js applications never buffer any data. These applications simply **output the data in chunks**. so user can easily view the videos or stream without interruption.

![streaming](https://dev-to-uploads.s3.amazonaws.com/i/170n2go0lk5z20951chf.jpg)

## 6. Easily Scalabale and Light weight :

Since it's a lightweight technology tool, **using Node.js for microservices architecture is a great choice.**
Accordingly, breaking the application logic into smaller modules, micro-services, instead of creating a single, large monolithic core, you enable better flexibility and lay the groundwork for further growth. As a result, it is much easier to add more micro-services on top of the existing ones than to integrate additional features with the basic app functionality.

# **Where we can use NodeJS?**

According to the latest survey made by NodeJS, **web applications are the top use case with the share of 85%**. Taking into account all the strengths and weaknesses of this JS run-time environment, we composed a list of the hands-on solutions where you can leverage the technology.

![web dev](https://dev-to-uploads.s3.amazonaws.com/i/c7e7qtqb2yhxvb3rzi6a.png)

## 1. Single Page Applications

A single-page app (SPA) involves the allocation of an entire application on one page. In that case, Node.js app development is a good fit for making SPAs due to its asynchronous data flow on the backend. The event loop "catches" **simultaneous client's requests which provides a smooth data update**. In practice, it **eliminates the necessity of refreshing the page every time to get new data**.

## 2. Streaming Applications

Streams are one of the fundamental concepts that power Node.js applications.

![stream](https://dev-to-uploads.s3.amazonaws.com/i/kw4uhqtl8npualm9rrfb.png)

* Every day we use streaming services for listening to music or watching videos. **Without downloading the content, we can bring your favourite TV series just on the internet**.

* So is Nodejs a good choice to stream data? Of course! It has built-in **streams module allowing you to transmit a huge amount of data in chunks, sequentially**. Thanks to this, you don't have to temporarily store or cache data in your application memory at all. Also, you can work on chunks while streaming, so e.g. encoding a video won't be a problem anymore.

## 3. Chat Application

![chat app](https://dev-to-uploads.s3.amazonaws.com/i/qf2im2vzm3lawbq1xsqx.png)

* Node.js provides all basic functionalities for building real-time chats of any complexity. In particular, Node has a **powerful Event API** that facilitates creating certain kinds of objects ("emitters") that **periodically emit named events "listened" by event handlers.** 

* Thanks to this functionality, Node.js makes it easy to implement server-side events and push notifications widely used in instant messaging and other real-time applications.

## 4. REST APIs

Application programming interfaces (APIs) based on representational state transfer (REST) hold a fundamental position in building modern enterprise software architectures.

**A REST Server simply provides access to resources and REST client accesses and modifies the resources using HTTP protocol**. Here each resource is identified by URIs/ global IDs. REST uses various representation to represent a resource like text, JSON, XML but JSON is the most popular one.

**Node.js offers Express.js framework to build the lightweight and fast REST APIs.**

## 5. Real Time Applications

Real-time collaboration applications offer a wide variety of software solutions for co-browsing, project management, video and audio conferencing.

![socket.io](https://dev-to-uploads.s3.amazonaws.com/i/2p8qjy6i0f4h2qw2gy1g.jpg)

Node.js is very good at **handling lots of I/O operations, you can use it to build a real-time application**, for example, a chat room where people can talk to each other in real-time. Or maybe a collaboration tool, where co-workers will work on the same document at the same time. **Building a video conference app** also won't be a problem. It is possible **thanks to Node's Events API and WebSockets.**

As in the case of the real-time chats, **Node's asynchronous and event-based architecture is a great fit for collaboration apps**. In these applications, many events and I/O requests occur concurrently. For example, several users can edit the same paragraph, comment, post messages, and attach media. Changes to one piece of content might be applied only after a cascade of events, where each step depends on the previous one.

## 6. Application Monitoring

Another common use-case in which web-sockets fits perfectly: **we can track website visitors and visualizing their interactions in real-time.** You could be gathering real-time stats from your user, or even moving it to the next level by introducing targeted interactions with your visitors by opening a communication channel when they reach a specific point in your site

Imagine how you could improve your business if you knew what your visitors were doing in real-time - if you could **visualize their interactions. With the real-time, two-way sockets of Node.js, now you can.**

## **Stacks Of NodeJS**

![stacks](https://dev-to-uploads.s3.amazonaws.com/i/fa59vfwl57bm7soio505.jpg)

> **MERN Stack** : MongoDB + ExpressJS + React+ NodeJS

> **MEAN Stack** : MongoDB + ExpressJS + Angular + NodeJS

> **MEVN Stack** : MongoDB + ExpressJS + VueJS+ NodeJS

## **Who Use NodeJS?**

**Node.js is increasingly becoming a go-to technology for multiple companies across the globe**. As Node.js emphasizes on concurrency, speed, and intensive data exchange along with employing push technology over web sockets, it has helped companies to build various applications such as social media apps, video and text chat engines, real-time tracking apps, online games and collaboration tools. Here are global giants who trusts NodeJs :

![companies](https://dev-to-uploads.s3.amazonaws.com/i/6b5n3yow6hdd792rqa2y.png)


**10 Global Companies that rely on NodeJS**

> 1. NASA
> 2. Netflix
> 3. PayPal
> 4. Uber
> 5. Linkedin
> 6. Medium
> 7. Trello
> 8. eBay
> 9. Groupon 
> 10. Walmart

## **Resources To learn**

**Tutorials**

> * [All Tutorials with categories](https://hackr.io/tutorials/learn-node-js?sort=upvotes)

> * [Step by step Nodejs guide](https://www.tutorialsteacher.com/nodejs/nodejs-tutorials)

> * [Cocenpts of nodejs - Javatpoint](https://www.javatpoint.com/nodejs-tutorial)

**Videos**

> * [NodeJS By Mosh](https://www.youtube.com/watch?v=TlB_eWDSMt4)

> * [NodeJS For beginners](https://www.youtube.com/watch?v=w-7RQ46RgxU&list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp)

> * [NodeJS Tuotrial By Edureka](https://www.youtube.com/watch?v=JnvKXcSI7yk)


**Courses**

> * [Complete NodeJS Developer - Andrew Mead](https://www.udemy.com/course/the-complete-nodejs-developer-course-2/)

> * [NodeJS - Academind by Maximilian](https://www.udemy.com/course/the-complete-nodejs-developer-course-2/)

> * [NodeJs Bootcamp - The Complete Backend](https://www.udemy.com/course/nodejs-express-mongodb-bootcamp/)

![nodejs impact on career](https://dev-to-uploads.s3.amazonaws.com/i/9its6fnhtbh92hchqnfn.png)

## **Conclusion :**

> "_This is simple, Node.js is a clear market winner. So, Now you know how NodeJS rule the Web Development world, why it is so popular and where it can be implemented. You can decide whether Node.js is a good fit for you, and launch your first web app with NodeJS._"

**References** : nodejs.org, software house, netguru

> _**"If you wanna CODE then start learn NODE…!"**_

Connect me on [Twitter](https://twitter.com/OzaKaran) and [LinkedIN](https://www.linkedin.com/in/karanoza/)


 If you want me to make an **article** on any concept then leave the topic down in the comments.

**Feedback are most welcome**