Do you node about NodeJS

Victor Torres
5 min readMay 4, 2021

In the field of Software Engineering you may be accustomed to the various options provided in the field, There are so many frameworks and languages. There are all kinds of packages to install. However once somebody becomes comfortable they may hesitate to give other ones a chance, some pounce at the opportunity while others may shy away. With all that in mind id love to inform you all about NodeJS.

What is NodeJS?

Node.js is a framework for writing server-side JavaScript applications. JavaScript is still the number one language used today. Node.js is built on top of the V8 JavaScript runtime and uses an event-driven, non-blocking input and output model that makes it perfect for data-intensive, real-time applications.

Node is often used to build back end services that communicate with client side applications. The applications receive and send data using the backends API. An API is an application programming interface that defines the interactions between multiple software applications or mixed hardware-software intermediaries. In layman's terms it serves as an interface between different programs so they can communicate.

To my surprise and maybe yours some of the biggest and leading companies in the world use Node for their backend. These companies include Linkedin, Netflix, Uber , NASA , eBay and Paypal. Obviously these aren't all of them but the ones I felt confident you may have heard of at least.

The Structure

Every browser has their own JavaScript engine that converts javascript into code so your computer may understand and render the applications. This is why JavasScript code can behave differently depending on the browser you're using.

Before Node, JavaScript could only be ran in the browser. In 2009 Ryan Dahl came up with an idea to execute JavaScript out its browser and the world changed. Ryan took chromes v8 engine , which was and still is the fastest Javascript engine available and embedded it inside a C++program, naming it Node.

Using JavaScript browsers provide different objects for us to carry out tasks. With Node, we have objects that allow us to manipulate the file system by creating and deleting folders, query databases and creating web serves to serve data. Only Chrome and Node contain the V8 engine, each perform at different run time environments , which give us access to different objects or tools to leverage the functions.

Input and Output

Input and output is referring to accessing to anything outside of the application. Once an application is running , it loads into the machines memory. That is what the CPU will mostly use when running your program.

Non-Blocking(Input/Output Asynchronous)

Node makes Asynchronous, non-blocking servers, which only use one thread to service all requests. This means an instance of Node makes the most out of a single thread. This means the server can serve a lot of request without requiring more server hardware; an economical pro.

When requests arrive at the server, they are serviced one at a time. However, when the code serviced needs to query the DB for example, it sends the callback to a second queue and the main request continues to run; it doesn’t wait. Now when the DB operation completes and returns, the corresponding callback is pulled out of the second queue and queued in a third queue where they are pending execution. When the engine gets a chance to execute something else, it picks up a callback from the third queue and executes it.

Blocking (Input/Output Synchronous)

Synchronous blocking operations is how some web servers, handle IO or network requests by default. Code reads from a file or database, your code then“blocks” everything after it from executing until that first request is finished. In that period, your machine is holding onto memory and processing time for a thread that is idle.

While the thread is stalled to carter other requests depends on your software. Most server software spawns more threads to handle the additional requests. Causing more memory and processing to be consumed.

I am not saying other types of frameworks can’t run code asynchronously, but you have to write more code to make it happen. Node runs asynchronously by default.

Give Node a chance ?!

Think of a website you use regularly. Chances are it’s responsive, beautiful and quick. All that is due to it being composed of HTML, CSS and JavaScript. Almost all sites use JavaScript framework for the front end of their apps. Their libraries provide features that make it trivial to implement the complex requirements of your apps.

To this day the most popular programming language is JavaScript. Developers who know JavaScript are in high demand, it powers the worlds most popular client-side frameworks. Now with node, it can be ran on the server side as well. This means as long as you know JavaScript you can be hired on as a fullstack developer; meaning higher pay. Building both the frontend and backend using the same language.

JavaScript worried me at first but it has become my favorite language. Knowing Node will make you a more valuable asset considering most jobs are in the process of implementing apps with a frontend and backend using the same language.

Knowledge is power

--

--

Victor Torres

Full Stack Software Engineer || Entrepreneur at heart , engineer by training. Comedian in the eyes off my peers.