What is NodeJS?
NodeJS is an open source server environment and free. NodeJS runs on various platforms(Windows, Linux, Unix, Mac OS X). NodeJS developed by Ryan Dahl. NodeJS is a platform built on chrome's JavaScript run-time for easily building fast and scalable network applications. NodeJS uses JavaScript on the server, an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
NodeJS runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser, single threaded, non-blocking, asynchronously programming, which is very memory efficient. This allows NodeJS to be very performant. NodeJS uses asynchronous programming.
NodeJS eliminates the waiting, and simply continues with the next request. NodeJS comes with several JavaScript libraries that help basic programming.
An Example NodeJS Application,
What NodeJS can do?
- can generate dynamic page content
- can create, open, read, write, delete, and close file on the server
- can collect form data
- can add, delete, modify data in your database
Event Loop
Event loop is what allows NodeJS to perform non-blocking I/O operations-despite the fact that JavaScript is single-threaded by offloading operations to the system kernel whenever possible. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When one of these operations completes, the kernel tells NodeJS so that the appropriate callback may be added to the poll queue to eventually be executed.
When NodeJS starts, it initializes the event loop, processes the provided input script which may make asyns API calls, schedule timers, or call process.nextTick() , then begins processing the event loop.
Use Cases
NodeJS is capable of handling an huge number of simultaneous connections with high throughput. NodeJS has been regarded as a full-stack JavaScript for serving both the client and the server-side applications. NodeJS works best for only a certain king of web applications.
use cases for web application development;
- Build Streaming Web Apps - NodeJS is an excellent choice for developing streaming web apps. NodeJS has built-in interface of writable and readable streams that can be easily and efficiently processed and monitored.
- Build Real-time Collaboration Tools - Real-time collaboration tools are basically software solutions widely used for project management. co-browsing, audio and video conferencing, collaborative documents editing
- Build Complex, Single-Page Applications - single-page applications have become a common approach nowadays.
- Build Real-time Chat Applications
- Build Microservices Architecture - microservices architecture is basically an approach to develop a web application as a group of small, independent services in which each service plays a unique role in business logic.
Other use cases;
- I/O Bound Applications
- JSON APIs based Applications
Advantages and Disadvantages of NodeJS
Advantages:
- Easy Scalability
- Easy to learn
- High Performance
- Fullstack JavaScript
- Large Community
- Extended Support
- Highly Extensible
- Advantage of Caching
- Offers the freedom to develop apps
- Getting support for commonly used tools
- Handles the requests simultaneously
Disadvantages:
- API interface is not stable
- The library is nothing good to write home about
- Not good for heavy computation
- Not good with relational databases
- Being an Asynchronous programming model
Node Package Manager(NPM)
Node Package Manager is two things,
First, it is an online repository for the publishing of open-source NodeJS projects.
Second, it is a command-line utility for interacting with said repository that aids package installation, version management and dependency management. A plethora of NodeJS libraries and applications are published on NPM and many more are added every day.
npm is a package manager for NodeJS with hundreds of thousands of packages.
Node Package Manager is used to manage dependencies for package and update the framework in every time, Reusable NodeJS components easily available through online repository. Build in scripting mechanism.
open-source developers use npm to share software. Many organizations also use npm to manage private development. All npm packages are defined in files called package.json. At least two fields must be present in the definition file: name and version.
npm includes a CLI that can be used to download and install software.
for example;
Comments
Post a Comment