TECH

Vol.60

author

Engineer

Y.M.

Getting Started with Node.js: What Is Server-Side JavaScript?

#WEB#blogging software#HTML#CSS#programming#エンジニア
Since around 2013, when I first became involved in web production, up through 2017, I have felt that the environment surrounding web development has been changing at a remarkable pace. Google Chrome overtook Internet Explorer in browser market share, smartphones rapidly became widespread, and websites have now become an essential part of everyday life.
stuffstuff

The Rise of Multi-Browser Support and the Move Away from Flash

Today, rather than supporting so-called legacy browsers such as Internet Explorer 6 or 7 — which once held large market shares — a much greater emphasis is placed on responsive design, cross-browser compatibility, and multi-browser support.
As the environments used to browse the internet evolved, development environments also changed alongside them.
Apple’s iOS, used on the iPhone, chose not to support Flash, which had once been standard on desktop browsers, and Android also gradually phased out Flash support. As smartphones became widespread, web design standards shifted to prioritize mobile compatibility, leading to a rapid decline in Flash-based web content.

JavaScript Gains Attention

This is where JavaScript began attracting major attention.
As Flash — which had originally been responsible for rich interactive content — was phased out, the industry shifted toward recreating those experiences using JavaScript instead.

As a result, many JavaScript libraries emerged. Among them, the most well-known is jQuery, which became a standard tool in web production environments.
Even jQuery underwent a major shift with the release of version 3.x in 2016, changing its direction by dropping support for legacy browsers and focusing more heavily on lightweight performance and efficiency.

In recent years, a wide variety of libraries, frameworks, and runtime environments have been developed to improve both development efficiency and performance.
Among them, one technology that attracted particular attention is Node.js, which enables JavaScript to run on the server side.

Node.js is often referred to as “server-side JavaScript.”
So what exactly is it, what characteristics does it have, and how does it differ from traditional web servers such as Apache?
These are the key points we will focus on.

stuffstuff

What Is Node.js?

Node.js is one of the environments used to execute JavaScript on the server side.
Today, when people refer to “server-side JavaScript,” Node.js is generally the most representative example.

The phrase “an environment for running JavaScript on the server” can feel a bit abstract at first. Personally, I found it easier to understand by comparing Node.js with traditional web servers such as Apache or nginx.

  • Using Node.js makes it possible to execute JavaScript on the server side.
  • Because you can build a web server using JavaScript itself, Node.js can also be used as an environment for publishing websites.

In a simplified sense, you could think of Node.js as being able to “serve a role similar to Apache.”
However, their characteristics and strengths are quite different, so Node.js is not a complete replacement in every situation.

The Background Behind the Rise of Node.js

The C10K (10,000 Clients) Problem

Illustration of the C10K (10,000 Clients) Problem

The C10K problem refers to a situation where a server becomes overloaded and crashes even when the hardware specifications themselves are not the issue.
This became a major challenge in web server architecture, and Node.js emerged as one of the solutions to address it.

Non-Blocking I/O

In traditional Apache-based architectures, one thread is created for each client request being processed.
With this approach, when the number of clients increases significantly, the number of threads also increases proportionally, resulting in heavy memory consumption. This is known as synchronous I/O.

As a solution, event-driven architectures were introduced, allowing processing to occur using a single thread.
An event-driven model handles many requests by repeatedly looping through them within a single thread.
This approach is also adopted by nginx and is referred to as asynchronous I/O.

However, another issue arises when performing heavy processing tasks: the entire process can slow down while waiting for those tasks to complete.
The idea behind non-blocking processing is to continue handling other tasks while waiting for time-consuming operations to finish.

Node.js adopts asynchronous, non-blocking I/O architecture.

About Node.js – Official Website
Beginner-Friendly: Understand What Node.js Is in 3 Minutes
Blocking I/O / Non-Blocking I/O

What You Can Do with Node.js

So, what exactly can Node.js do? What is it good at, what are its weaknesses, and how can it be used?
Let’s take a closer look.

Advantages

  • No language barrier
    Because both the frontend and backend can be handled using the same language, JavaScript, the learning cost can be reduced.
    It also lowers the barrier for frontend engineers to work with servers.
  • Excellent for real-time processing (asynchronous processing)
    Because Node.js adopts non-blocking I/O, it excels at asynchronous processing.
    Even servers with relatively low specifications can achieve strong performance using a single-threaded architecture.
    It is particularly well suited for real-time applications such as chat systems and live notifications.

Disadvantages

  • Implementation cost
    Many popular shared hosting services do not provide a Node.js environment by default.
    To use Node.js, it is often necessary to build a server environment using services such as VPS hosting.
    That said, Node.js has also lowered the barrier for frontend engineers to handle server-side development.
  • Server resources may go underutilized
    Because Node.js is fundamentally single-threaded, it cannot fully utilize the performance of multi-core servers in its default configuration.

Examples of Using Node.js

  • Real-time web applications and notifications
    Processing that requires real-time updates and notifications, such as those used in social games and live services.

[Detailed Overview] How Pigg Life Works

  • Chat web applications
    Using Socket.IO makes it relatively easy to build chat systems and real-time communication features.

Learn Socket.IO by Building a Chat Application

Express: A Framework for Node.js

Express, a framework for Node.js

Node.js has a framework called Express.
Express makes it possible to build applications with Node.js quickly and with minimal setup.

Because it supports View Engines, developers can create web applications using Node.js while also building the visual interface with HTML templates.

Official Express Website

Companies Using Node.js

Companies and organizations such as PayPal and NASA have adopted Node.js for backend development.
The fact that such major companies and institutions are actively using Node.js suggests that it has the potential to become an important mainstream technology for the future of the web.

PayPal Migrates Backend from Java to JavaScript
NASA Open API

Summary

In this article, we explored the key concepts necessary for understanding Node.js.
Node.js originally emerged as one of the solutions to the C10K problem, but that was already several years ago. Today, it feels as though Node.js has naturally become one of the standard options available in modern web development.

In the next article, we will build an environment where Node.js can run on a server using nginx.

PREV
Vol.59Improving UI Design Quality Thro…
NEXT
Vol.61Practical code design using Sass…

MORE FOR YOU