Node

Node.JS

Node.js is a JavaScript runtime environment that runs on the V8 engine. It is designed on a event-driven pattern, having event loop built into the runtime itself, instead of having an external library (like for example Event Machine for Ruby or Twisted for Python). In contrast to other mainstream programming languages (especially in the time of making Node.js, around 2009) asynchronous pattern was used as one of the core concepts, while having it all run in one thread..

Let’s decompose this a bit, and try to explain each of the key concepts mentioned one by one. “JavaScript runtime environment” basically means that Node.js is an program which allows us to run JavaScript code outside of the browser. This is an important note, because it enables developers to write back-end applications using JavaScript, which was previously used just on front-end. Being a pioneer in this field, but also having some luck with timing (due to increasing popularity of JavaScript at the time), Node.js gained great popularity among development community.

Event loop is a concept which enables Node.js to work asynchronously without actually creating multiple threads. It is initialized as soon as the Node process is created, and is running as long as the actual application is running. In it’s core it is a simple loop which goes through multiple phases in each cycle, where each phase has it’s own queue of callbacks that need to be executed. All callbacks in each phase queue will be executed before next phase starts, unless there has been maximum number of callbacks executed (which will throw an error). During the callback execution, new callbacks can be added to queues, and when there is no more callbacks loop will end. Asynchronous tasks will basically have callbacks on “idle” waiting for a “ping” from the system to be added to appropriate phase in the next event loop cycle. That way Node actually simulates multi-threading approach without actually creating multiple threads. More about event loop you can read here.

Node.js System Workflow Visualized

Node.js runtime simplified (source)

One of the big parts in making Node.js project into a success story is the community that surrounds it. The fact that Node.js is open-sourced helped a lot in building community around it, since anybody could fix bugs that would create problems on any specific project. Having that model in mind, using other open-source libraries (3rd party) in projects became much normalized in Node.js environment. In play comes npm (Node Package Manager), which simplified and streamlined managing open-source libraries on the one hand, and using them on the other. Today npm is the biggest software registry (based on their documentation) and is a tool used by basically every JS / TS developer in the world.

There are many open-source libraries published on npm which are used by Node.js developers on a daily basis, such as express (unopinionated web framework), socket.io (real-time, bidirectional communication), passport (authentication middleware with additional support for most of the authentication methods that exist – oAuth, JWT, basic auth etc.), sequelize (SQL ORM), mongoose (MongoDB ORM), dotenv (environment file loader), and many more.

Some of the big companies that are using Node.js are Netflix, NASA, Trello, PayPal, Linkedin, Twitter, Yahoo, eBay, Medium, Yandex, and many more…

Our team has couple of Node.js experts who are with us at ExN from the beginning, and have been ensuring that our Node.js teams maintain strong knowledge and high quality outputs. Many of the projects we had, and many of the projects we still work on, are based on Node.js and we are always thrilled to tackle new challenges in it.

If you think that Node.js would be a good match for your project, or you are wondering whether that is the case, schedule a free call with our experts, and we can help you understand anything around this piece of technology.