NodeJS
Introduction
- Developed by Ryan Dahl.
- Created with the aim of creating real-time websites with push capabilities (websockets).
- NodeJS is an open source, cross platform runtime environment for server-side and networking applications.
- Build on V8 engine, Chrome’s JavaScript engine.
- Uses event-driven, non-blocking I/O model which makes NodeJS lightweight and efficient.
- Ideal for data-intensive real-time applications that run across distributed devices.
- NodeJS comes with several JavaScript libraries that help basic programming.
- NodeJS eco-system ‘npm’ is the largest in the world for open source libraries.
● Advantages
- Ability to use single programming language from one end of the application to the other end.
- NodeJS applications are easy to scale both horizontally and vertically.
- Delivers improved performance since V8 engine compile the JS code into machine code directly.
- Performance increased via caching modules into memory after the first use.
- Easily extensible.
- Support for common tools like unit testing.
- Well build ‘npm’ package manager and it’s large number of reusable modules.
● Disadvantages
- Even though there are number of libraries available, the actual number of robust libraries is comparatively low.
- Not suitable for computationally intensive tasks.
- Asynchronous programming model is complex than synchronous model.
● Node package manager
- Reusable NodeJS components easily available through online repository.
- Build in version and dependency management.
- Build in scripting mechanism.
- Performance increased via caching modules into memory after the first use.
- Global installations will be available throughout the system while local installations will only be available for that particular application.
- By default all the dependencies will get installed to ‘node_modules’ directory.
- ‘package.json’ contains all information related to the NodeJS application. The file be placed in the root directory of the application.
- ‘package.json’ will contain name, version, author, repository, required node version, scripts and dependencies etc.
● Node require
- NodeJS follows commonJS pattern when loading modules.
- Require modules get loaded synchronously and will be cached after the first use.
- If the file does not start with ./, ../, or / module is not a core module NodeJS will look the dependency on the node_modules directory.
Comments
Post a Comment