Numbers Don’t Lie
Let’s play a game called Truth or Dare. Not the middle-school sleepover variety, but one a group of CTOs might think is fun.
If you could use 33% fewer lines of code in an app that then loaded twice as fast, would you do it? For many Fortune 500 companies like PayPal, the answer was a no-brainer. Those are the exact stats PayPal measured when it made the switch to Node.js.
And PayPal isn’t alone. Netflix did the same and reduced its load times significantly. eBay created a live-chat app with Node.js. Countless start-ups have used Node as well. So what’s the deal? Why have companies large and small (and brand-new) adopted this technology? And should you follow suit?
The Magic Elixir
So how does Node.js act like a magician, shrinking code and letting videos stream faster? How does it keep pulling rabbits out of the hats of some of the world’s most dynamic companies?
Let’s start with a definition of what Node.js is. It is a “runtime environment,” or where the software and hardware infrastructures intersect in real-time when an app or program is actually running. What’s truly unique about Node. js is that allows for “JavaScript everywhere,” meaning that web developers can use a frontend programming language on the backend, in what is known as “full-stack development.”
No more writing code twice, once for the frontend and another time for the backend. Netflix engineers were doing this, at considerable expense of time and money, and decided to go with a fairly new solution in Node.js and it has never looked back.
JS Everywhere
One advantage of “JavaScript everywhere” is that it is the world’s most used programming language and being able to deploy it for Node.js instantly made Node an appealing solution. The learning curve for Node isn’t steep, as long as you are fluent in JS and understand the basics of backend development issues.
Another plus is that Node, due to JS, has seen the growth of a thriving community of users. There is a library of 650,000 JS packages (modules) that Node developers can use, all housed in the Node Package Manager (npm). Since Node.js is open source and is built on Google Chrome V8, it is constantly being updated and improved with security patches and performance boosters.
A Single Thread
Node.js runs on a basic architecture that is single-threaded and event-based, and these features allow it to handle up to a million concurrent connections. In practical terms, Node excels in any kind of “real-time” application such as chats or streaming. Maintaining a live connection to a server is what eBay wanted in its Talk feature—in addition to deploying other services in an I/O framework. Node.js was the perfect solution.
But the single-threaded approach also means that Node.js is scalable and can grow along with your enterprise. While Node is great for Netflix and lots of other huge companies, it performs well with smaller projects as well. Again, this is due to its JavaScript capability. A start-up doesn’t need to hire someone for the frontend and another for the backend—Node accommodates “cross-functional” teams where you can take an “all-hands-on-deck” approach to problem-solving.
Microservices
With Node.js, you can take the idea of “cross-functional” teams one step further by chunking the app into smaller units called microservices. That way, you can set up separate teams that work on just a portion of the code. Each microservice can be tested separately or even written in a different coding language. You can outsource certain portions and keep others in-house because the microservice approach is scalable in many agile ways.
These nimble teams are easier to work with compared to overhauling the entire codebase whenever you implement changes. One example might involve a digital marketing company that is much more concerned with content management and chat than with email. The microservice approach offered through Node.js lets small teams handle just the parts of the app that need attention if the other parts are operating efficiently. Without Node.js, adjusting one part meant diving into the entire code, which is laborious and unnecessary.
It’s Not Perfect
But keep in mind that Node.js isn’t the right magician for every birthday party. If your app is a simple CRUD app—meaning it Creates, Reads, Updates, and Deletes—then Node is completely overkill and most of its power will be wasted.
This is why you want to consult with those who know before making a decision. We’ve worked with Node.js on many projects, and we’ve also steered clients to other solutions. We never take a “one-size-fits-all” approach and would love to discuss your options with you. Without a doubt, Node.js is a dynamic tool and a game-changer in many important ways.