Every ten or so years, a programming language emerges that changes the face of software development. From C++ in the 80’s, to Java in the 90’s, to C# .Net in the 2000’s, each iteration transforms how people work and develop software systems. Node.js is that platform of the 2010’s, combining highly asynchronous development with a wide breadth of plugins to create 50%+ reductions in development time. Its single-threaded execution, high-level of configurability, and large plugin ecosystem make it the ideal platform for high-performance web application development.
Single-Threaded Execution Forces Good Design (No Blocking Loops)
At first, the single-threaded nature of Node.js may seem counter-intuitive. Why would a single-threaded web platform perform better than the multi-threaded platforms like PHP and ASP.NET? Wouldn’t a single-threaded app be able to serve fewer concurrent users?
The answer is that Node.js forces good design. All calls to the file system, database, or other applications need to be programmed asynchronously. Every call must be non-blocking, and large amounts of overhead are saved by reducing thread switching and worker processes.
Whereas ASP.NET and PHP attempt to abstract concurrency into the platform and work around programmers’ poorly structured code, Node.js forces programmers to write in such a way as to make all code well structured, distributed, and scalable.
Highly Configurable – Anything Is Possible
The single best feature of Node.js is its extremely high level of configurability. Almost every plugin provides the full open source and enables developers to view how it works and make changes as necessary.
Although open source software has been around for decades, what makes the Node.js open source different is the ease of making changes. Since Node.js code often turns out to be minimal and the language is interpreted, making modifications to open source code has never been this easy.
Developers Are Required to Understand Web Protocol Implementation Details
The underlying platform in Node.js is built to expose the full capabilities of the HTTP protocol. Although this can be daunting at first, it again forces developers to learn how raw HTTP works before being able to code successful applications.
Instead of working with intermediary functions, developers work with the underlying building blocks. File uploads, for example, require developers to work with the data in the way the browser sends it, instead of through abstracted functions that hide both the complexity and some of the capabilities. When combined with the flexibility of client side HTM5, a new class of applications is possible where end-to-end applications can be built without using any compiled or interpreted bytecode.
Back-end, Front-end, Test Cases, and Utilities Can Be Built in the Same Language
Another great feature of Node.js is its ease of deployment and capability to run as both a server and an application. The same platform can both be used to create the Web / Application Server, as well as the client-side application to test that web server.
In addition, Node.js serves as a command-line scripting platform for Utility programs or Jobs. Although command-line scripting is possible with PHP, it has not been developed to the same level as with the Node.js engine. Node.js can run on any Windows PC with a single executable, and requires no installation or configuration.
Great Plugin Ecosystem (NPM)
Another impressive feature of Node.js is its extensive plugin library. Built in a similar fashion to Linux updaters like yum and apt-get, the npm utility enables access to over 100,000 plugin packages. Plugins exist for integration to almost any database. In contrast to yum and apt-get, however, package downloads and updates are mostly flawless, since each library keeps its own set of dependencies and does not require version matching between different packages.
In addition to integration plugins, a large selection of libraries exists to help optimize development. From libraries that simplify asynchronous development to libraries that make array manipulation easier, thousands of tools are available to help reduce development time and produce cleaner code. And each library is open source, enabling developers to both review the source code and create improvements.
Persistent Connections (Real-time Data, Chat, Push Notifications)
In contrast to PHP and ASP.NET, Node.js also makes development of modern apps using technology such as persistent connections easy. Persistent connections are used in most systems for real-time updates, push notifications, and chat.
Traditionally, web apps required the client to send a request to the server, and then receive an immediate response. This only allowed the client to receive new information when it made a request, and requests performed more often than once per minute would quickly bog down the server for large applications.
Node.js was built from the ground up as a server for managing persistent connections. Persistent connections keep the connection open for several minutes or hours. During this time, the client and server can communicate and send messages in both directions. This provides for the faster interactivity necessary in modern applications that are based around social or multi-user interfaces.
As a simple analogy, Node.js transforms the web server from a telegraph into the telephone.
The Learning Curve Excludes Amateurs
Last but not least, the learning curve of Node.js helps exclude amateurs and primarily attracts experienced developers. Since building new applications requires a thorough understanding of the underlying principles of HTTP and solid development practices, Node.js helps exclude novice programmers who would find it easier to develop on other platforms. This helps both create a more robust community, and makes it easier to find good talent for web application development.
Given all these advantages, it’s no wonder that many developers are transitioning to Node.js and the platform has been embraced by most major brands. The next several years will be exciting to watch Node.js become the dominant platform for web application development.
Written by Andrew Palczewski
About the Author
Andrew Palczewski is CEO of apHarmony, a Chicago software development company. He holds a Master's degree in Computer Engineering from the University of Illinois at Urbana-Champaign and has over ten years' experience in managing development of software projects.