Share this article Return
What is Node.js?
Why choose Node.js for web development
Event Driven Architecture
It's a family of styles that allow components to communicate through asynchronous messages. Systems based on event-based styles are often organized as a loosely coupled federation of components that trigger behavior in other components through events.
A variety of event styles exist, for example:
Crosscutting concerns are addressed by aspect style.aspect style is a module style, event-based style - runtime style, so it's important not to mix them up.
Real-time web apps? No problem!!
RTA is an application program that functions within a time frame that the user senses as immediate or current. The latency has to be less than a defined value, usually measured in seconds. The use of RTAs in your applications is called the Real Time computing (RTC).
- Sharing and reusing: It is all fine to share packages of library code. If a developer faces any problem, the Node Package Manager (NPM), with its repository of more than 50,000 packages, helps the developer with the solutions. Updating, sharing and reusing of code are much easier now.
- Streams in Node.js: As Node.js is event-driven, tackling of I/O bound tasks are extremely good. The streams are UNIX pipes which make it easy reading the data from the source and pipe it to the destination
- Event-based server: An Event-based & non-blocking driven server is best suited if the web applications get to handle a large number of real-time users.
- Different modules: Availability of file system I/O, networking binary data, data streams and other functions is important. Node.js’s modules use an API designed to reduce the complexity of writing server
- Applications. These applications can run on MacOS, Microsoft Windows, NonStop, and UNIX servers.
- Differentiation with PHP: Node.js is primarily used to build network programs such as Web servers. The biggest difference between Node.js and PHP is that most functions in PHP block until completion while
- Functions in Node.js : Functions in node.js are designed to be non-blocking. Node.js has brought event-driven programming to web servers. The freelance web designer community is using Node.js for a long time.
NPM Package Manager:
The main advantage, from the perspective of a developer, is simple: local package installation.
- npm lets you choose between global and local installation (with local being the default). In the local installation, the packages are installed into a directory called `npm_modules` inside the current (i.e. your app's) directory. Node automatically makes all locally installed packages available to a running app, so there are no conflicts with other apps' packages.
- If an npm package has other dependencies, they are installed into that package's directory, NOT into a shared one. I.e. if my project requires package A and B, and both of these require incompatible versions of package C, they will each get their own copy that is local to them. No more dependency conflicts!
- you can just copy and paste the project files and install dependencies on other system using npm. There is no need to copy your entire project files like node_modules or any.
- If a package provides command-line tools, it can still be installed system-wide, by using the '-g' flag.
Of course, this approach means that packages may be duplicated on the filesystem, but with the size of most packages vs. the size of current hard drives, that's really not so much of an issue.
When data streaming is the real deal
I/O bound applications are at a greater advantage with the way streams are managed in node.js. Data Streaming is one of the most powerful applications of node.js given that there are very few to choose from. As a majority of the data that come into the systems are in the form of streams, a lot of time can be saved during the process. The ultimate aim is to utilize the time during another operation, and node.js facilitates just that.
also refer our article on: 6 Ways To Make Your Node JS Web App Faster