Why Node.js Is the Ideal Language for High-Performance Web Applications

NodeJSEvery 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 language 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 language 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 language 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.

Also, since Node.js uses JavaScript as the programming language, the same programming methodologies and libraries can be used for both front-end and back-end development.

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.
Google+

RSS Twitter LinkedIn Facebook Email

14 thoughts on “Why Node.js Is the Ideal Language for High-Performance Web Applications”

    1. That’s correct that semantically Node.js is a platform / framework, and the programming language itself is JavaScript. I chose the phrase “programming language” to make the article more accessible to a wider audience, and quite frankly, I would consider the evolutionary step of moving JavaScript to the server-side enough of a departure to set Node.js on an equal footing with the afore-mentioned languages. There are plenty of venues for debating semantics, however I would prefer to welcome comments regarding additional applications, benefits, or contrasts to other development platforms.

  1. There are two problems with your last point: a. It is not true b. Feels little elitist

    A platform/language should have a mixture of enthusiasts, beginners, intermediates, evangelists and experts, for it to be widely adopted and popular.

    I don’t think node would be this popular, if it is too hard for “amateurs” to learn it , adopt it or be excited by it.

    1. AJ, that’s an interesting point. By amateurs, I did not mean beginners to the language, I meant beginners to programming. My line of thought is that many of the precepts – asynchronous execution / callbacks, low-level HTTP development, could be challenging for a beginner when compared with the ease of development in PHP or Rails. What kind of applications do you envision that beginner programmers would write in Node.js?

      1. What you’re saying is just plain wrong. Node is one of the top choices for new programmers and is really, really easy to pick up.

      2. Although you do make some valid points, it’s still not true. I am an ‘amateur’ programmer but found it quite easy to learn NodeJS due to Express and similar middleware. Express abstracts all the low level executions so the developer doesn’t have to deal with them directly, they are already written for us due to the countless NPM modules. Overall good article.

  2. As a Developer that values good designed applications with well written code I’m amazed by node.js. It’s going to be a little bit hard to break the inertia of the current development trend that favors easy to learn new languages but once it does I do believe it’s going to be a significant change to the development environment as a whole.
    It’s going to take a combination of clever tools/people to crate educational material to make it easy for new people to understand the changes to the typical paradigm.

  3. Andrew, I’m curious where you’d honestly rate your level of confirmation bias against JavaScript/Node.js current popularity? I know some of your reasons are explicitly because of popularity, but some of them are not necessarily so.

    I’m looking for an answer that is at the level of taking a thesis on (and defending it against alternatives), but merely just the abstract if possible.

    1. Hi Farrin, nice to hear from you! As you can imagine, it’s difficult for a person to measure their own confirmation bias. What I can tell you is that I’m a contrarian by nature, so my endorsement and our team’s use of Node.js is based on practical experience and disenchantment with other languages such as C#/ASP.NET, PHP, Ruby/Rails, and Python/Django. I’ll also add that I believe there is a difference between popularity and hype: popularity leads to better plugins and tools, while hype is mostly hot air. I think Node.js is at the point where it’s no longer a media darling, but is starting to shake up the way business gets done. The popularity of the platform and NPM (the plugin ecosystem that has expanded to host other JavaScript platforms as well) provides a very compelling set of tools for web application development.

      Is it the right tool for every application? I’d say no. If you are putting together a traditional web app with server-side HTML composition, then you probably won’t take advantage of the best features of the platform. Stick with PHP or ASP.NET to ensure an easy deployment. On the other hand, if you’re building a modern AJAX app or an SPA, Node.js / Express provides a killer set of tools and minimalist syntax that will make development a breeze. The anonymous functions and prototypes enable some very interesting design patterns…

  4. Good summary of why Node.js is gaining a lot developer mindshare over the past five years. BUT I would argue that JavaScript/Node.js is a great language for self-taught amateurs, and that all programming languages should be, and in general are, open to such types of on-boarding of users.

    For Red Hat we see Node.js as ideal as the server-side for mobile applications as well as pure web applications, whilst we have a lot of Java for traditional more heavy-weight enterprise deployments (though there are some interesting models for lighter-weight Java too).

    Arguably the new paradigm of Bi-Modal IT (Gartner) or Systems of Engagement (Geoffrey Moore) allows for a twin-track approach to enterprise IT: Core-IT (traditional) and Fast-IT (new), and I would see Node.js as the right tool for many solutions in the latter Fast-IT category — smaller scale codebase, flexible and fast-changing, but supporting large numbers of concurrent users. Such solutions generally rely on integrations to existing systems in Core-IT — so both approaches are needed.

  5. I think that it is worth pointing out that the node event loop is a single thread. You can do plenty of multithreaded operations in node by nunning moduals in seperate processes. Node brilliantly leaves managing threads and cpu cores to the OS.

  6. Interesting article Andrew, but is comparing Node.js to two essentially “dying” technologies meaningful? Perhaps Node.js would not come out as strong a winner if you had compared it to modern web development frameworks.

    In any case, what distinguishes Node from the rest is its asynchronous design, as you mentioned and that is it’s best feature. However, Node suffers from it’s very ugly syntax, which makes it harder to maintain. And anyone working in the software industry knows that maintenance takes the lion’s share of resources in business.

    I agree that the principle of asynchronous single threaded design will continue to gain momentum, but in other modern development frameworks as well as Node. One example of this is the Lambda service on AWS: first released as a pure Node.js implementation; now offering Java as an alternative syntax but with the same asynchronous front-end.

    1. Hi Pierre, thanks for the thoughtful comment. It sounds like one of the roadblocks you found with Node.js is the asynchronous syntax. It does have a steep learning curve, it took me several months to fully develop the design patterns necessary to build apps successfully. What I would recommend is diving into the toolkits async, promises, and lodash, if you are still interested in pursuing Node.js development.

Leave a Reply

Your email address will not be published. Required fields are marked *