NodeJs is strong

Mikhail Panfilov
3 min readApr 22, 2019

Abuse it. Abuse like it the last abuse in you life.

Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. Node.js lets developers use JavaScript to write command line tools and for server-side scripting — running scripts server-side to produce dynamic web page content before the page is sent to the user’s web browser. Consequently, Node.js represents a “JavaScript everywhere” paradigm, unifying web application development around a single programming language, rather than different languages for server side and client side scripts.

Stop. Why NodeJs?

Because it’s fast, it’s simple.

We can do the server side rendering with our favourite frameworks (VueJs, Angular, React and etc). We can do a thousands micro services with easy scalability and high availability.

The main feature of NodeJs is fully asynchronous.

What’s mean?

Simply put, when you send a request to the database, you register a new event in libuv and it will check when the response comes. When you get the response, libuv will see it and execute the callback you want.

What the hell is event loop and libuv?

Event loop

The event loop is an infinite loop, which in each of its iterations causes callbacks of triggered events like an api and database responses, operations with files event and etc.

NodeJs official site:
The event loop is what allows NodeJs to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.

Libiv

But what is libuv? It’s event loop realisation for NodeJs and others async realisations. Each event that you register for asynchronous execution falls into the libuv.

Libuv official page:
The library provides much more than a simple abstraction over different I/O polling mechanisms: ‘handles’ and ‘streams’ provide a high level abstraction for sockets and other entities; cross-platform file I/O and threading functionality is also provided, amongst other things.

Why do we like asynchrony?

Because 90% of the work is spent on modern applications for connections with databases and third-party API services and communication with each other.

Asynchronous code execution allows you not to block new clients until the old ones receive answers from databases and etc. It’s can boost hundreds or more times compared to synchronous code.

But we have a threads in sync code, what’s better?

In case when we have a lot of requests to the database or third-party api asynchrony is definitely better. Multithreading will be better when you have many processor operations like calculations or data processing.

Huge community

Javascript has the largest community in the world, as well as a huge number of ready-made solutions (npm) that are ideal for the rapid development of your applications.

And finally

Do we all like to use npm drive development? So?

Avoid the npm drive development

Be careful with the installed dependencies, they can give you problems at the right time.

Conclusion

NodeJs is a great tool that will save you a lot of resources and your own strength. Thanks to the package manager you are provided with a large selection of ready-made solutions for your tasks and huge community will help you to resolve difficult issues.

Just use the NodeJs and enjoy.

📝 Read this story later in Journal.

🗞 Wake up every Sunday morning to the week’s most noteworthy Tech stories, opinions, and news waiting in your inbox: Get the noteworthy newsletter >

--

--