Node.js
Nodejs
About Nodejs
As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications. In the following "hello world" example, many connections can be handled concurrently. Upon each connection, the callback is fired, but if there is no work to be done, Node.js will sleep. This is in contrast to today's more popular concurrency approach, which employs OS threads. Thread-based networking is wasteful and complex to implement. Furthermore, because there are no locks, Node.js users are not concerned about deadlocking the process. Because almost no function in Node.js does I/O directly, the process never blocks. Scalable systems are very feasible to develop in Node.js because nothing blocks.
Getting started with Nodejs
The installer package supplied on the NodeJS official website makes the installation of NodeJS and NPM simple.
- Download the installer from the Nodejs package
- Run the installer.
- Follow the installer steps, agree to the license agreement, and click the next button.
const http = require('http');
const hostname = 'localhost';
const port = 8080;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Advantages of using NodeJs
- Open-source
Because Node.js is an open-source runtime environment, it is free to use under the MIT license. Node.js is a cross-platform programming language that works on Windows, Mac, and Linux.
- Java Script language
Node js code is written in the Javascript programming language for both the frontend and the backend. As a developer, you do not need to learn a new server-side programming language to use Node js.
- Easily use unit testing
- Easily work with RestApi
Disadvantages of Node.Js
- Relational databases are not well supported.
Relational databases typically act weirdly when working with node js. If the issue persists, Nodejs developers can use a NoSql database (MongoDB). It removes the need for extra labor to learn new databases.
- Large-scale applications are ineffective.
Node JS is best suited for lightweight applications because it does not support multi-threaded programming.
When and How Should Node.JS Be Used
- https://www.simform.com/nodejs-advantages-disadvantages/
- Advantages & Disadvantage by Shailendra Sethiyas by
- https://www.w3schools.com/nodejs/nodejs_get_started.asp




Comments
Post a Comment