This is what official Node.js website tells us, and this is where we suggest you to start learning Node.js.
A couple of years ago Elinext team made a decision to experiment with Node.js, and today we feel like it’s time to share our impressions with you.
Frankly speaking, our developers weren’t quite satisfied with these definitions, and least of all we wanted to work with a black box. That’s why we dug into a source code, standard library, and libuv library where all the asynchronous and nonblocking primitives were implemented.
Digging deeper: Node.js applications
The next step was to study all the applied libraries and tools. This allowed our team to understand how to work with Node.js and get outside of its strengths and weaknesses.
It turned out that there is no universal web framework that Node.js community concentrates on. We discovered some well-elaborated and powerful frameworks, and here are our favourites:
Express.js, known as a part of a popular MEAN stack, was probably the most efficient of the frameworks we tested. Our team was impressed by clearly arranged documentation, in comparison with Node.js documentation in general. The main benefits of Express.js lie in its routing capabilities, easy configuration and customization, and middleware modules that allow you to perform additional tasks on request and response.
Hapi.js. is very similar to Express.js, as it provides API for building HTTP servers in Node.js. However, Hapi.js is prominent for its rich set of features and plugins, while Express.js offers fewer out-of-the-box functionality. With that in mind, Hapi.js can cover a wider range of use cases which makes it a better fit for large-scale projects.
Koa.js has proven to be great fit for web applications and APIs. Our attention was drawn by generators Koa.js uses to work with callbacks and error-handling, thus making the application more readable.
Node.js: Pros and Cons
Well, what’s so special about Node.js? Having worked with this technology on a range of projects, we formed our own list of advantages and disadvantages that come with it. Let us share some.
- Microservices architecture. The platform is fast and highly scalable, as it consists of microservices that can be built on top of the existing solutions as well as integrated with one another. This means that you can break the whole project into small modules which are independent, though tightly coupled with one another.
- Asynchronous non-blocking code. Using Node.js, you benefit from asynchronous non-blocking code, as resources are consumed by web servers more economically, so that they can support more parallel client connections for the applications where input-output operations are run. We would say that the implementation of such a code is comparatively good as it is in Ruby, Java, or Python.
- Node package manager. You can enrich existing ecosystem with npm – free and open-source package manager for Node.js featuring free tools and libraries which are being actively developed and enhanced.
- No basic libraries or tools. Each of the applications has a lot of alternatives which makes it harder to choose a right stack. The only possible way we see is to check and choose between a plenty of them, as often applied documentation doesn’t offer a comprehensive picture of advantages and disadvantages.
- Poor for relational data access. Although some relational databases, such as PostgreSQL or RethinkDB seem to work better for Node.js applications with each release, their support in Node.js is still underdeveloped.
- Unsuitable for heavy processing. When it comes to CPU intensive operation and the thread is occupied with heavy computation, Node.js benefits of non-blocking I/O model melt away, as all the incoming requests are being blocked.
- Multithreading is not supported. That’s why many developers consider the technology unsuitable for complicated web applications. However, our experience shows that it can be used as efficiently as php for large-scale projects when clustering multiple Node.js processes. Simply put, to have multiple threads, you need to run multiple processes as well.
Node.js: Elinext choice
Apparently, Node.js is not a one-size-fits-all solution for web development, however, none of the popular technology is. For a standard web application which actively exploits database and requires good speed and scalable architecture, it surely can bring significant performance increase.
This works well for many of Elinext projects featuring social network, IoT solutions, chats, video streaming apps and e-learning solutions where the speed and intensive data management mattered much.
Our switch to Node.js in a range of projects was fast and smooth, with a low learning curve. The main pitfalls emerged on the way of selecting the right libraries, studying them and comparing them with one another. Our main focus now is on the integration of multiple Node.js tools, their completion and future enhancements.