Kanngongkanngoen

Node.js Fundamentals: Runtime and Blocking vs. Non-Blocking I/O

💡 Key takeaways

Learn the difference between JavaScript and the Node.js runtime, the basics of blocking and non-blocking I/O, and how to begin running JavaScript files with Node.js.

This introduction explains what Node.js does, how it differs from the JavaScript language, and why I/O behavior matters when building server-side applications. The referenced lesson was updated in 2021; use current project requirements and the official release schedule when choosing a Node.js version.

JavaScript is a language; Node.js is a runtime

JavaScript is a programming language. Node.js is a runtime environment that lets JavaScript run outside a web browser. This distinction helps explain why a developer can use JavaScript for server-side programs as well as browser interfaces. For an introduction to the runtime, see the official Node.js introduction.

Blocking and non-blocking I/O

A blocking operation makes the program wait for that operation to finish before continuing along the same flow. With non-blocking I/O, the program can continue with other work while an input or output operation is handled. Node.js uses an event loop to coordinate many such operations.

Non-blocking does not mean every task runs at the same time or becomes faster. Long-running JavaScript or callbacks can still hold up the event loop. Read the Node.js event loop guide for more detail.

Getting started

Before working with Node.js, become comfortable with JavaScript basics, install Node.js, and try running a JavaScript file from a terminal. Because the lesson dates from 2021, check the Node.js release schedule rather than relying on an old installation walkthrough.

This article focuses on Node.js runtime and I/O fundamentals; it is not a step-by-step Express.js website build.

KGK

Kanngongkanngoen Editorial Team

We create clear educational content about personal finance, investing, and debt management, with an emphasis on accuracy and transparency.