These questions cover the 5 sections of the Node.js overview and are organized into 3 topic clusters. No answers are provided — the goal is to test your understanding of Node.js's execution model, how it compares to PHP, and how to implement basic servers and Express applications.
The questions mix conceptual understanding, technical reasoning, and cross-reference connections to other overviews.
Cluster 1: Execution Model & Architecture (Sections 1–2)
The overview's diagram shows PHP with "Process starts → Handle request → Process ends" while Node.js shows "Process runs continuously → app.listen(3000) → Handles many requests without restarting." Explain the fundamental architectural difference. What happens to variables in memory between requests in PHP vs Node.js?
The overview lists four implications: "State persists," "No cold start," "Single-threaded event loop," and "You control the server." For each, explain what it means and give one practical consequence for application design. How does "state persists" relate to the State Management overview's discussion of statelessness?
The intro states "Node.js IS the server. Unlike PHP which runs inside Apache." Reference the diagram: where does Apache fit in the PHP flow? What does app.listen(3000) do in Node.js? Why is this distinction important for deployment?
The tutorial modules list 5 modules: Hello World, HTTP Server, Express Basics, Form Handling, and REST API. Trace the learning path: what foundational concept does Module 1 establish? How does Module 2 build on it? Why is Express (Module 3) introduced before form handling (Module 4)?
The overview mentions "The event loop concept" in Module 1, and "Single-threaded event loop" as an implication. How does a single-threaded process handle "many concurrent connections" (from the diagram)? How does this differ from PHP's "multiple processes/threads" (from the comparison table)?
Cluster 2: PHP vs Node.js Comparison (Section 3)
Using the 8-row comparison table, contrast how PHP and Node.js differ in Execution, Server, and Concurrency. How do these three rows form a coherent picture of the two architectures? Reference the diagram from Section 1 in your answer.
The comparison table shows GET parameters: $_GET['name'] (PHP) vs req.query.name (Node.js). Similarly, POST body: $_POST['email'] vs req.body.email. How does the request object pattern (req.query, req.body) reflect Node.js's object-oriented API design? Why does PHP use global arrays?
The table shows PHP has built-in $_SESSION while Node.js "Requires middleware (express-session)." Why doesn't Node.js have built-in session support? How does this reflect Node.js's "minimal core, rich ecosystem" philosophy?
The "Best for" row states PHP suits "Traditional websites, CMSs" while Node.js excels at "APIs, real-time apps, microservices." Using the architectural differences from the first three rows, explain WHY Node.js is better for real-time apps. How does the Connections overview's WebSocket discussion relate?
Compare "Package manager" (Composer vs npm) with the tutorial modules. Module 3 teaches "npm and package management" and Module 4 uses "Body parsing middleware." How does the middleware ecosystem compensate for Node.js's minimal core? Give two examples of functionality built-in to PHP but requiring npm packages in Node.js.
Cluster 3: Implementation & Code (Sections 4–5)
The "Running the Demos" section shows node hello.js. Compare this to running a PHP script through Apache. What happens when you run node hello.js — does it return output and exit, or does it start a server? How does this reflect the execution model difference?
The Quick Reference shows core modules: http, fs, path, url. The Basic HTTP Server code uses http.createServer((req, res) => { ... }) and server.listen(3000). What does createServer return? What does listen do? How does this relate to "You control the server" from the implications list?
The Express code shows three app.use() calls: express.json(), express.urlencoded({ extended: true }), and express.static('public'). What does each middleware do? Why is middleware loaded before defining routes? How does this relate to the comparison table showing Node.js needs middleware for sessions?
Compare the Basic HTTP Server code (http.createServer, res.writeHead, res.end) with Express (app.get(), res.send(), res.json()). What complexity does Express abstract away? Why does the tutorial teach Module 2 (bare http) before Module 3 (Express)?
The Express code shows app.get('/api/users/:id', (req, res) => { res.json({ id: req.params.id }) }). How does the :id path parameter work? How does res.json() differ from res.send()? How does this route pattern relate to the REST overview's discussion of resource-based URLs?