What is NodeJS ?
NodeJS is an open-source and a cross platform runtime environment to develop server side and networking applications. NodeJS is written in javascript, so the file extension would be “ .js ”.
Node.js = Runtime Environment + JavaScript Library
What can NodeJS do ?
- Generate dynamic page content.
- Create, open, read, write and delete files on the server.
- Collect form data.
- Add, delete, modify data on the database.
Where to use NodeJS ?
Following are the areas where NodeJS proves itself as a perfect technology.
- I/O bound Applications
- Data Streaming Applications
- JSON APIs based Applications
- Single Page Applications
Where Not to use NodeJS ?
It is not advisable to use Node.js for CPU intensive applications.
Getting started …
- First of all you should download and install NodeJS into your PC. For that go through the official NodeJS website. -> https://nodejs.org
- You can follow the same steps which was mentioned in my blog post on “ExpressJS” and instead of the code you typed to test ExpressJS, type the below code in the “index.js” file.
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('Hello World!');
}).listen(3000);
- To run file give the below command on the cmd
node index.js
- Start your internet browser, and type in the address: http://localhost:3000
What is a module in NodeJS ?
- These modules are same as javascript libraries. Set of functions which you may need to include into your application.
- NodeJS has a set of built-in modules which you can use without any installation. The 1st line of the above code shows how to import modules into your application.
Advantages of NodeJS
- Open Source - ( free to use )
- Javascript Language - ( no need to learn a new programming language. Both frontend and back end can be coded using Javascript )
- NodeJS is fast - ( NodeJS uses the V8 engine which the process of compiling the javascript code is fast )
- Unit testing - ( There are many javascript unit testing tools available today. As the coding can be done in javascript it is a big advantage )
- Streaming data - ( It is easy to develop streaming-based applications using NodeJS )
Disadvantages of NodeJS
- Not effective with large scale applications - ( Because NodeJS does not support multi threaded programming )
- Inconsistent
- Not suited for CPU-intensive tasks - ( If we use NodeJS for CPU-intensive tasks it will slower our application )
- Poorly supported to relational databases - ( Developer can use NoSQL databases. So if the developer does not know about it, they should put an effort to learn about the new databases )
Comments
Post a Comment