Node.js was initially released in 2009. Since then, it already has made its mark around the world. Many big​ players ​have​ ​leveraged​ ​it​ ​in​ ​production,​ ​including​ ​​LinkedIn​,​ ​Netflix, Medium,​ ​Github or Groupon or even NASA.

The push into its popularity equally comes from developer community as from customers themselves. Developers love Node.js because, it is already mature, stable, the footprint is low and it has a fast launch-time, in addition to being very suitable for serverless functions, having a small learning curve and an extensive community. While the clients love it because it is asynchronous, scalable, easily maintained – something truly inevitable in nowadays software development cycles.

Hence, whether you are a CTO, a software architect or a senior developer choosing the right backend technology for your project and looking to build the next big thing, you’d better join the Node.js revolution and here I’d like to share why.

A programming language? A framework? What is Node.js?

First and foremost before diving into why we prefer Node.js let’s begin with clearly defining, what is Node.js. There are several misconceptions around what Node.js is. A programming language? A framework? A browser feature? Well, none of the latter.

It is NOT a programming language dedicated to developing backend apps, while it DOES employ one of the most popular ones. Neither it is a framework or a library, but there are JavaScript frameworks made particularly to run on Node.js environment, like Express.js.

Node.js is an open-source, asynchronous environment where Javascript can run outside a web browser and has a set of core libraries which allow working with operating system APIs (networking, file system, etc).

What are the differences running Javascript in browsers vs in Node.js?

There is one more misconception, where Node.js and internet browsers are sometimes mixed. Let me break it down piece by piece. 

Almost any website you visit has some Javascript code which is executed in a browser. Node.js does the same. It means that browsers and Node.js can interpret the same language. 

Some engines can execute Javascript. One of the many is Google v8. The element that overlaps the most between browsers and Node.js environment, is the engine. However, everything else is different, including and particularly, the set of functionalities added by browsers and Node.js:

  • Browsers allow you to develop in a sandboxed environment. They add features such as HTML manipulation, web APIs (fetch API, indexed db, push notifications). However, browsers restrict you from OS APIs.
  • Node.js allows you to use OS APIs by native Node.js modules which means that things you can build are, well, kind of, unlimited.

What can be done with Node.js?

Node.js can do pretty much everything that other backend technologies can do, but then with some key added benefits.

Node.js​ ​is​ ​a​ ​great​ ​fit​ ​for​ ​Single-Page​ ​Applications​ ​(SPAs)​ ​thanks​ ​to​ ​its​ ​efficient​ ​handling​ ​of asynchronous​ ​calls​ ​and​ ​heavy​ ​I/O​ ​workloads​ ​characteristic​ ​of​ ​these​ ​applications.​ ​Node.js’s​ ​event​ ​loop ​ensures​ ​smooth​ ​transitions between​ ​views​ ​and​ ​seamless​ ​data​ ​updates.​ ​Also,​ ​Node.js​ ​works​ ​well​ ​with​ ​data-driven​ ​SPAs,​ ​where​ ​the server​ ​acts​ ​as​ ​a​ ​backend​ ​that​ ​provides​ ​data​ ​to​ ​the​ ​client​ ​whereas​ ​the​ ​client​ ​does​ ​all​ ​the​ ​HTML rendering.

Node.js​ ​is​ ​excellent​ ​for​ ​the​ ​development​ ​of​ streaming​ ​applications (like Netflix)​ ​thanks​ ​to​ ​its​ ​native Stream​ ​API.​ ​In​ ​particular,​ ​Node.js​ ​has​ ​an​ ​interface​ ​of​ ​readable​ ​and​ ​writable​ ​streams​ ​that​ ​can​ ​be processed​ ​and​ ​monitored​ ​very​ ​efficiently without much effort for maintaining the proper RAM usage.

While Node.js can do pretty much everything, there is a list, which summarizes, what Node.js is best used for:

  • Asynchronous flow allows non-blocking I/O;
  • Powerful data streaming API;
  • Multi-threading support;
  • Node.js can run any code which might be converted to Javascript. One of the most popular choices is to use Typescript, which gives a more stable ground during development;
  • Also, while there is Google v8 engine, it is written in c++. It allows you to execute even c++ or c code;
  • If it is not enough for you and you are into exotic Frankensteins (you probably have a solid reason for it), it supports web assembly as well;

Why should I include Node.js in my tech stack?

It’s obvious that Javascript and Node.js have a vast community. Node.js package manager (npm) is taking care of packages and it has already more than 1.300.000 of them. It leads to more packages to choose from that entail more open-sourced libraries. Therefore, because packages might be shared among front-end and back-end, it makes full-stack development cheaper.

  • The learning curve is smaller to come from the frontend to Node.js backend;
  • Some of the patterns, guidelines, best practices might be reused;
  • Package manager npm allows us to use the same dependencies across frontend and backend;
  • C++, C support allows high-performance binding of libraries such as Tensorflow.
  • One​ ​Language​ ​on​ ​Both​ ​the​ ​Front-​ ​and​ ​the​ ​Back-end

When should I include Node.js in my tech stack?

You might use Node.js if the task you are facing, contains:

  • Big data streaming;
  • Some web service exposed using HTTP API;
  • Real time flow;
  • Act as a proxy;
  • Server side rendering;
  • Manual work automation scripts, prototypes, proof of concepts;

However, this list contains only abstract use cases. I bet your problem is unique and has its own caveats. Feel free to experiment!

What do clients think about Node.js?

Clients are hyped about how easy it is to kick off a proof of concept using Node.js and evolve it up until a huge, scalable, efficient cloud service. And if they are not yet, they should be. Why? Node.js provides reusability among frontend and backend, easier maintainability, cross-platform, rich community, which as a result saves money, time, expands the accessibility to skills.

One of the success stories of Node.js’s reusability between front-end and backend is Bustle – an online media publication. Its versatile nature, resulted in everyone on the Bustle team being able to work on anything, anywhere as needed – the lines between frontend engineers and backend engineers didn’t blur; it disappeared.

Think of how much an engineer’s morning can cost to a company – we’ve saved countless mornings/afternoons by creating an environment that uses one language and consistent tooling across the stack. It takes three seconds to deploy any layer of the stack now. With all the kerfuffle involved in trying to remember how to deploy some legacy Ember.js app we had, it definitely saved countless hours of back and forth. Also, onboarding is much more efficient. A new hire can commit and deploy to production on their first day.

– Zachary Foster software engineer at Bustle.

Still doubting if Node.js will suffice?

Node.js has its caveats, just as everything else. It includes asynchronous flow, which might be harder to develop. As well as synchronous operations, that can block the event loop. By misusing the asynchronous idea of Node.js can lead to low performance. But do not worry, with the right knowledge and guidance it is cleanly solvable.

And if you are still doubting whether Node.js is safe, mature, fast, well documented, or if it has a community you can learn from? I can tell you – yes, yes, YES! Just dedicate some research before choosing the tool for the problem to solve and if you are going for Node.js, you can be relaxed about your project being in a popular, stable, tested environment.

Why leading companies use Node.js and why?

Previously I have mentioned that clients prefer Node.js, as a technology that could enable an easy kick off a proof-of-concept with the capacity to grow it to a huge, scalable, efficient cloud service. That is why the list of companies that use Node.js, either partly or as their main tool, is impressive: Walmart, Netflix, Viricity, or The Bustle Digital Group, and of course TeleSoftas.

Due to its unique characteristics Node.js is the preferred solution to be applied at IoT systems, Single Page Applications (SPA’s), Real-Time Collaborations Tools (e.g. Trello), Real-Time​ ​Chats and many others.

These ​are​ ​only​ ​the​ ​tip​ ​of​ ​the​ ​iceberg​ ​of​ ​many more businesses ​that​ have ​embraced Node.js​ in their tech stack.​ ​There are many​ ​more​ major ​players​ ​using​ ​Node.js,​ such as ​Microsoft,​ ​Google,​ ​Yahoo, Mozilla​ ​or​ ​Github.​ ​The​ ​technology​ ​creates​ ​countless​ ​possibilities​ ​in​ ​development,​ ​and​ ​there certainly will be​ ​more​ ​up-and-coming​ ​Node.js-based​ ​apps​ ​conquering​ ​the​ ​market. 

Interesting facts

  • In 2018 Node.js reached 1 billion downloads
  • Npm on average has 835 new packages each day. However, 61% of packages on npm did not publish a release in the last 12 months.
  • 46% of Node.js developers are in the group age 25-35.
  • 78% of all downloads of Node.js are for Linux, 17% Windows and 5% macOS.
  • All versions of Node.js show a 40% year-by-year growth of downloads.
  • Node.js can boost your business productivity. Only 4% of companies say Node.js has had no impact.

Source: Node.js user survey report.

Further reading

This was more of an introduction with what is Node.js and what it is capable of. There are enormous amounts of technical stuff to analyse to get a more solid understanding about it. We suggest to dive into these topics so that you could broaden your knowledge:

  • Code structure, the backbone for HTTP web server;
  • Callback hell;
  • What exactly makes Node async?
  • Native Node modules (streams, processes, threads, file system, many more);
  • Usage in frontend development;
  • Node package manager;
  • Module system (Common js vs ES modules);
  • Deno vs Node;
  • Debugging.

Žilvinas Jocius
This article was written by TeleSoftas Software Engineer Žilvinas Jocius. For more insights from Žilvinas follow him on his Linkedin.