Why is it worth developing your project in Node.js?
First of all, using Node.js as your server technology gives your team a great boost that comes from using the same language on both the front end and the back end. This, means that your team is more efficient and cross-functional, which, in turn, leads to lower development costs.
You can also reuse and share the code between the frontend and the backend parts of your application, which speeds up the development process.
On top of that, the Node.js community is constantly growing – the number of StackOverflow questions is steadily increasing, so the knowledge base for the technology is widely available.
The fact that the whole Node.js technology stack is open-source and free is also great news.
Finally, Node offers a great package management solutions, npm or yarn, and the amount of available open-source tools in npm’s registry is massive and growing fast.
These are just a few of the many advantages of Node.js that you should consider when choosing the technology for your next project.
Good use cases
Node.js is a good choice for applications that have to process a high volume of short messages requiring low latency. Such systems are called real-time applications (RTAs), and they can be easily developed with Node.js.
Thanks to its specifications, Node.js will be a good choice for the real-time collaborative drawing/editing-type apps, where you can watch the document being modified live by someone else (such as Trello, Dropbox Paper or Google Docs).
The list of RTAs that can be effortlessly developed with Node.js is much longer. One of the most popular ones are live-chat and instant-messaging apps.
Node will also be the right choice, if you want to create a video conference app that will work with specific hardware or VoIP. Additionally, you might want to consider Node.js for online gaming apps or e-commerce transaction software, where online data is of much importance.
Node.js is very efficient with real-time applications: it facilitates handling multiple client requests, enables sharing and reusing packages of library code, and the data sync between the client and server happens very fast.
Fast and scalable environment.
Ruby on Rails might not be sufficient in terms of speed, if you have a ton of requests. Node.js will prove useful in situations when something faster and more scalable than Rails is needed. Node’s ability to process many requests with low response times, as well as sharing things such as validation code between the client and server, make it a great fit for modern web applications that carry out lots of processing on the client’s side.
For these reasons, Node.js is a popular choice among "single-page application" sites, where all the rendering is done on the client’s side, and the backend only provides a JSON API.
Node.js also comes in handy, when you want to process high volumes of IO-bound requests. Historically, it wasn’t really that efficient if a lot of CPU processing was involved, mainly due to how your code is being run on a single-threaded process. These days, there are a lot of new tools and ways to work around it, for instance, Node.js Worker Threads. Yet, if it's primarily just shuffling data around, then it will be quite efficient, because a single instance can serve a lot more requests with the same hardware, compared to the usual "thick" application server (as is the case with Rails).
When might Node.js not be the best idea?
Even though Node.js is – in many cases – the perfect fit for building applications, there are still some bad use cases when you shouldn't consider using it.
In the past, the first thing that came to mind were heavy-computing apps. Node.js is based on an event-driven, non-blocking I/O model, and, for the sake of simplicity, it will run your code on a single thread.. CPU-heavy operations will just block incoming requests, rendering the biggest advantage of Node.js useless. Thankfully, Worker Threads (introduced in Node.js v10.5.0) gave us some tools to mitigate that. Still, if you are considering building CPU-heavy software, you might want to try a different, more suitable, technology that will give you better results.
Finally, using Node.js would be superfluous for simple HTML or CRUD applications in which you don't need a separate API, and all data comes directly from the server.
Your application might be marginally more scalable, but don't expect more traffic coming to your app just because you used Node.js.
In such cases, you should stick to such proven frameworks as Ruby.
There are more things to consider before kicking off with Node.js. Many packages for Node.js applications are available in npm. The community is vibrant, the technology is becoming more mature, and npm is the largest available repository at the moment.
Yet, packages vary in their quality. Sometimes, you can still encounter issues with packages supported only by individual users and not maintained properly; for instance, when connecting your Node app to an obscure or old database system.
Where to start?
First of all, go to the official web page of Node.js (nodejs.org) and download the Node.js package.
Later on, we need to install the Node.js package manager to install and manage the dependencies in our project easily.
Visit npmjs.com and follow the installation instructions.
Now, we are ready to write some code.
The best starting point for the Node.js is the official guide, from which you can learn the core concepts of Node.js. In the Node.js guide, you can find the answer to one of the most important questions: How to build a simple Node.js server?
After that, you will be ready to learn by building your own applications.
Learning materials and resources
Who to follow?
- TJ Holowaychuk
- Dan Shaw
- Mikeal Rogers
- Fedor Indutny
- Guillermo Rauch
- Gergely Nemeth
- Thomas Watson
- Myles Borins
- Matteo Collina
- Sindre Sorhus