We are going to deliver a sequence of posts on “How to develop Applications using Node JS, Express JS, Angular JS, Mongo DB, Redis, and RESTful WebServices“.
We will discuss all these posts on Windows Environment only. There is no much difference in Node JS Platform installation and developing applications in other OS Environments.
In this post, we are going to discuss about some basics of Node JS Platform.
- What is Node JS?
- What is NOT Node JS?
- Features of Node JS
- Advantages of Node JS
- Limitations of Node JS
- Who uses Node JS Platform?
- Node JS Applications
What is Node JS?
Node JS is an Open Source Java Script Platform used to develop fast and scalable server-side and networking applications very easily.
Ryan Dahl is a big fan of “Google’s Gmail”. He was impressed by Gmail performance and started created new Platform.
Ryan Dahl has developed a Server-Side Platform “Node JS” in 2009 on top of Google’s V8 Engine. That means Node JS applications run on V8 Engine.
We can run Node JS applications on most of the OS Platforms like Windows, Linux, Mac etc.
Official Website for Node JS Platform: https://nodejs.org/en/
What is NOT Node JS?
Node JS is a Platform. It is not a Framework or Web Framework. It is not a Language.
It is a Platform which contains thousands of thousands of modules to develop wide variety of applications. We can install base Node JS Platform and update all your application required modules very easily.
Node JS “Module” is also known as Package. Now onwards, when we refer Module means Node JS Package.
Node JS is not for Multi-Threaded applications. It follows Single Thread with Event Loop architecture. If you don’t know what is “Even Loop” architecture, don’t get tense at this moment. We will discuss on “What is Event Loop and How Node JS deals with multiple requests” in coming posts.
We will discuss how to setup Node JS Base Platform and how to add/install required modules at required time in coming posts.
Features of Node JS
- ModularityMajor advantage of Node JS Platform is that it’s modularity. Each and every functionality is divided and implemented as a separate module or package. When we install Node JS Platform, by default it installs only few modules. If our application requires other modules, then we can easily install and configure then at any point of our application development phases.Node JS has thousands of thousands modules. Some modules were developed by Node JS Community and some were by Third-party Clients. We will discuss and provide some examples about these modules in coming posts.
While writing this post, Node JS Platform supports the following number of packages.
- We can check this updates on its official website: https://www.npmjs.com/
Some of the Node JS Modules are written in Java Script and some are in C/C++ Language. It’s 40% modules are written in JS and 60% modules are written C/C++.
- Express JSNode JS is used to develop Server-side Java Script. It also contains a separate module for Web Application Framework i.e. Express JS.
- Non-blocking or Asynchronous IONode JS supports Non-blocking IO i.e. it uses Asynchronous IO Model to interact with File system or to do Socket communication or network communication.Asynchronous IO Model means if IO processing is taking more time, then it permits other processing to continue before the transmission has finished.
Java Developers are very much familiar about Blocking IO and Non-Blocking IO. Java IO package follows Blocking IO or Synchronous IO Architecture whereas Java NIO 2 follows Non-Blocking IO or Asynchronous IO Architecture.
- Event-Driven Asynchronous Platform
Node JS Platform follows Even-Driven Loop architecture to interact or handle requests. We will discuss in details about “Even-Drive Loop” in coming posts.
- MongoDB Wrappers API
- Jade Template EngineNode JS platform supports many template engines to write HTML. Default template engine supported by Node JS is “Jade”.
Jade is a whitespace-sensitive template engine for developing HTML applications very easily.We can write template pages once and reuse them very easily to reduce development time. We will discuss how to install and write Jade templates in a separate post.
- Web ServerWe can develop and use HTTP Web Server within no time. We need to use http package to implement Web Server. We will discuss one post on how to install http package and develop a Web Server.
- Better Socket APINode JS Platform provides very good Socket Module API to develop Real-time, Multi-User Chat and Multi-Player Gaming Applications very easily. It supports Unix Socket programming like pipe().
Advantages of Node JS
- One Language and One Data Format
We need to use one and only one language to write whole applications i.e. Java Script. We need to code all layers from UI to Controller to Business Layer to Persistence Layer (From Front-End to Back-End) in Java Script only.All layers from Front-End to Back-End support same Data Format i.e. JSON (Java Script Object Notation). UI Layer Angular JS Supports JSON Format, Server-Side Scripts written in Express JS supports JSON Format and Back-end MongoDB NO SQL supports same JSON Format.
- Open SourceNode JS is Open Source Module. It provides many modules for free to use in our applications.
- Highly ScalableTo improve our application performance, we will scale our infrastructure. There are two ways to scale any application:
- Horizontal Scaling
- Vertical Scaling
Vertical Scalability means adding more resources to a single node. Horizontal Scalability means adding more nodes to a system.
Node JS uses Horizontal Scaling instead of Vertical Scaling to our applications. It’s consistent with today’s Cloud Technology trend.
If we develop our UI and Data Intensive applications by using MEAN Stack, we
can achieve very high performance. MEAN Stands for MongoDB, Express JS, Angular JS and Node JS.
- Caching ModulesNode JS Modules are cached once they are loaded into application for first time. Multiple calls to load a module may not cause the module code to be executed multiple times.
- Less Problems with Concurrency
Node JS does not follow Multi-Thread architecture. It follows Single-Thread with Event Loop Architecture. It serves any number of requests without any issues.
Node JS does NOT need to handle pooling of requests to a set of threads. That’s why it has less overhead to handle multiple requests concurrently.
- Easy to Extend and Lightweight
We can install only required modules and use them to develop applications. Whenever we need to add new feature or module, we can easily extend it.
By following this approach, we can also achieve very light-weight nature into our applications.
- Faster Development and Easy to Maintain
As Node JS Platform had already provided support for many modules, we can use them and develop wide variety of applications within no time. We can develop and maintain Node JS applications very easily.
- REST API
Node JS Platform supports developing RESTful Web Services API very easily.
- Many Development Frameworks and Tools
We can get many development tools like IDE and UI Frameworks to develop Node JS applications very easily.
- Active Development Community
Node JS Development Community is very active in adding new modules or packages to existing modules to support wide variety of applications development.
- Unit Testing
In Node JS applications, we need to write whole code in Java Script. Today we have many Java Script Unit Testing frameworks and tools like Jasmin Framework.
- Streaming Data
We can easily develop Streaming-based data applications by using Node JS.
- Creating Servers
Node JS Platform has some built-in API to develop or create HTTP Server, DNS Server, TCP Server etc very easily or quickly.
- It can handle thousands of concurrent connections with minimal overhead (CPU/Memory) on a single process
- Easy Module Loading process
It is very easy to load required Node JS Modules into Node JS Applications. We just need to use require() statement in our application. It is similar to “import” statement in Java Programming language. We will discuss about require() in detail with some examples in coming posts.
Limitations of Node JS
- It does NOT support Multi-threading programming.
- It does support for Computational Intensive Tasks. Node JS struggles in handling of very high computational intensive tasks, because whenever it does something long running task, it will queue all remaining incoming requests, because it follows Single-Thread Architecture with Event Loop.
- Don’t use Node JS for Blocking/Synchronous and CPU-intensive tasks.
- Unstable API – Node JS is still in Beta stage and most of its modules are in unstable state. It’s not ready for Production or Live Systems.
Who uses Node JS Platform
Now-a-Days many people are using Node JS Platform to develop and maintain their applications. Some of the popular companies who are using Node JS Platform are;
- DOW JONES
- Twelephone (It is a service for making calls right from Twitter account)
- PINT Web Platform (PWP)
- Cloud9 IDE
- Chess (It is an online game available on facebook.com)
Node JS Applications
We can use Node JS Platform to develop the following kind of applications.
- Network applications
- Asynchronous Events
- Intelligent Networking Proxies
- Proxy Server
- Multiplayer Game Applications
- Data Intensive Real-time applications
- Web Applications
- High Definition(HD) Voice and Video Communications
- File Uploading Tools
- Process Monitoring Tools
- Many-To-Many Instant Chatting Applications
- Many-To-Many Instant Messing Applications
- HTTP Web Server
- Real-time Logistics Systems
- Streaming Server
- High Concurrency Applications
- Communication Hubs
- DNS Server
- Static File Server
- TCP Server
- Stock-Trading Dashboard
In coming post, we will discuss about “How to setup Node JS Base Platform” and also about “Node JS Components“.