The State Of Node

2022-12-10

So, how is Node.js doing in 2022/23? Pretty darn good, it seems. Global adoption of Node.js is still growing, and along with it grows and matures its ecosystem. It has become one of the most popular choices for web development. Over 30 million websites, or just over 2% of all websites (according to W3Techs Survey) are now powered by Node.js. Among them are Netflix, Twitter, Github, Spotify, PayPal and Ebay, just to name a few big ones. Also, the platform itself has matured with fewer deprecations and less breaking changes in the annual major version upgrade. This was expected, of course, after years of rapid changes and improvements.

It is hard to separate the rise of Node.js from the rise of JavaScript. The breakthrough that was reached in 2015 with the release of the ECMAScript 6 standard really pushed Node.js forward. Its full adoption by the Node.js platform itself and by packages in the npm repository, which is one of the world’s largest software repositories, took several years. The standard was refined and improved by the three subsequent ECMAScript versions released between 2016 and 2018. Since then the dust has settled and perhaps the state of JavaScript and Node.js right now is comparable to the state of Java after the SE6 release in 2006 when Java was widely considered as “mature”.

Node.js has a strong standing in web development and in the DevOps community. Moreover, it is now also being recognised as a serious contender for enterprise applications. According to the Node.js community, 43% of all Node developers say they’re using Node in enterprise applications. This has very likely something to do with the growth of microservice architectures in recent years that allow engineers to divide large applications into collections of loosely coupled services that are developed, deployed and maintained individually. With its small footprint and short turnaround time, Node.js appears to be ideal for this.

Node.js

To understand the success of Node.js in large scale web applications and enterprise applications, one must look at four orthogonal technologies, namely Node.js itself, microservices, CI/CD automation, and Kubernetes. Node.js makes it possible to quickly create web services without compromising on efficiency and resource utilisation. The microservice architecture provides the framework for achieving high modularity and scalability. Microservices are easier to understand, develop and test compared to monolithic applications. Their lifecycle is automated with CI/CD pipelines and finally, the containerised microservices are orchestrated by and deployed on Kubernetes.

What does this all mean in business terms? It’s quite simple actually. Using these four technologies, it is possible to achieve much faster software lifecycles and therefore accelerate time-to-market by an order of magnitude. While in the past, large business applications went through 2-weeks, 4-weeks, or even longer release cycles, with each release demanding painstaking planning and accuracy, a modern CI/CD pipeline can deploy a microservice update to production in minutes. Kubernetes provides the orchestration and high availability, which is important for high-grade service level objectives, such as triple-nine (and higher) online availability.

You would be right to conclude that Node.js, microservices and CI/CD together enable a highly agile work process. If you recall that agile software development is based on the principle of using small iterations to bring software from the planning stage into production thus creating tangible value quickly, this is exactly what the mentioned technologies allow us to put into practice. Continuous deployment implies that there aren’t any more release cycles and that new features, fixes and improvements go into production as soon as they are ready. They do so without human intervention once they are committed and pass all tests. It is easy to understand the role of DevOps and CI/CD in agile practice, but what role exactly does Node.js play and how is it benefiting the agile process?

The keyword here is productivity. As a dynamically typed, high-abstraction, interpreted language, such as JavaScript enables a level of productivity that is well above that of statically typed compiled languages such as C#, Java and even Golang. Notable productivity boosters are JavaScript’s dynamic object model (based on JSON) and the single-thread event loop model of Node.js, both providing conceptual simplicity and increasing the speed of development. Designing data structures and performing non-blocking I/O and multitasking operations is straightforward in Node.js. It is also trivial to create a web server using nothing but Node.js built-in library functions. The npm repository provides software modules for every conceivable use case. Therefore, development with Node.js and npm modules can perhaps be likened to fitting Lego blocks together into a larger application.

High productivity and conceptual simplicity yields additional advantages. Developers are (unsurprisingly) happier with tools that make them more productive. Managers achieve better results with happy and productive teams. JavaScript being both simple and mainstream means that is easier to find experienced developers. – But… can you use Node.js for demanding high-quality enterprise applications, say real-time processing of massive data? Well, yes, though you have to look closely at the requirements. Node.js is ideally suited for massive parallel I/O and request processing. This includes a lot of typical business applications, such as inventory control, logistics, financial analytics, booking and reservation, transaction processing and communication systems. However, Node.js is not ideal for heavy computational tasks, or if multi-threaded processing is required.

With this in mind, Node.js covers most “typical” requirements in the enterprise and it really shines as a web service platform, especially for lightweight, modular REST-based architectures. Currently at version 19, the Node.js library can be considered mature. The npm repository offers production-grade components for every conceivable type of application and the npm package manager comes with built-in security auditing. There are many different application frameworks for backend development. In addition to the widely used express.js framework, there is hapi.js, meteor.js, koa.js, fastify.js and socket.io just to name a few, each one with their own ecosystem. The choice depends on your architectural preferences, target platforms, level of abstraction, database integration and performance requirements. That being said, there is no “best” framework nor any that would fit all requirements. Express.js is simple, Koa is MVC plus context objects, Meteor emphasises full-stack development with event propagation, Fastify is based on plugins and scopes, Hapi emphasises REST, and so on.

Many contemporary enterprise applications are now being programmed in TypeScript, a superset of JavaScript that adds static typing to the language. TypeScript programs need to be compiled to JavaScript before they can be executed on a JavaScript engine. The obvious advantage of TypeScript is that it prevents type conversion errors, which according to the TypeScript community make up 15%-20% of all bugs in a typical JavaScript program. TypeScript is therefore perceived as being the “better” language. I would caution against this simplistic perception, however, because using TypeScript comes at a heavy cost. Defining and enforcing static types increases lines of code, development time and therefore decreases programmer productivity. It also introduces an additional compilation step into the software development cycle. The effort being spent thus could outweigh the advantages.

If you decide that a statically typed, compiled language is best for your software project, then JavaScript may simply not be the optimal server language choice. In that case, why not use a language that compiles to native code? Then you also get significant performance advantages (for free). Just saying.