Search lands in PR-5.1 (Pagefind).

Explanation Beginner

Chapter 2 Updated

JavaScript on the Server

Servers, V8, ECMAScript, and how your JavaScript gets to machine code.

  • Full 22m
  • Revision 5m
  • Flow 2m

Client, server, request, response

The loop every backend app sits inside.

  • Server = remote computer that serves clients over a network.
  • Client knows the server’s IP address (e.g. 142.250.193.206 for google.com).
  • Loop: client sends request → server processes → server returns response.
  • Response can be HTML, JSON, bytes, a stream — doesn’t matter, same shape.

JS breaks out of the browser

Why Node.js mattered culturally, not just technically.

  • Before Node, JS was browser-only: no file system, no sockets, no DB.
  • Backend required a second language (PHP, Ruby, Python, Java).
  • Node took V8 out of Chrome and wrapped it with server-side capability.
  • Result: one language for frontend and backend — full-stack JavaScript.

V8 is a C++ app you can embed

The engine, not the runtime.

  • V8 = Google’s open-source JS + WASM engine, written in C++.
  • Implements the ECMAScript standard; runs on Windows, macOS, Linux; x64 / IA-32 / ARM.
  • Embeddable — any C++ program can include V8. Node.js is one such program.
  • Doesn’t interpret JS — compiles it to machine code.

ECMAScript vs superpowers

What V8 can't do that Node.js can.

  • ECMAScript defines the language: variables, functions, loops, promises, classes.
  • ECMAScript says nothing about files, sockets, HTTP, databases.
  • V8 alone: executes JS logic. Can’t open a file.
  • Node.js adds fs, http, net, os, crypto, stream, child_process — the “superpowers”.
  • Runtime = V8 + Node APIs. That’s the formula.

From `let x = 42` to binary

The four levels your code passes through.

  • (1) JavaScript — the source you write.
  • (2) V8 (C++) — parses to AST, runs through Ignition + TurboFan.
  • (3) Assembly — mnemonics like MOV, ADD, JMP.
  • (4) Machine code — pure binary 0110 1010 … your CPU executes.
  • Both assembly and machine code are low-level: close to hardware, 1:1 with instructions.

Comments

Comments are disabled in this environment. Set PUBLIC_GISCUS_REPO, PUBLIC_GISCUS_REPO_ID, and PUBLIC_GISCUS_CATEGORY_ID to enable.