HTML and CSS Reference
In-Depth Information
Server-Side JavaScript
with Node.js
N etscape pushed JavaScript on the server way back in 1996. Since then, several
others have tried to do the same, yet none of these projects have made a big impact on
the developer community. That is, until 2009, when Ryan Dahl released the Node.js
runtime. At the same time, CommonJS, an attempt at a standard library specification
for JavaScript, is rapidly gaining attention and involvement from several server-side
JavaScript library authors and users alike. Server-side JavaScript is happening, and
it's going to be big.
In this chapter we will use test-driven development to develop a small server-side
application using Node. Through this exercise we'll get to know Node and its con-
ventions, work with JavaScript in a more predictable environment than browsers,
and draw from our experience with TDD and evented programming from previous
chapters to produce the backend of an in-browser chat application that we will
finish in the next chapter.
14.1 The Node.js Runtime
Node.js—“Evented I/O for V8 JavaScript”—is an evented server-side JavaScript
runtime implemented on top of Google's V8 engine, the same engine that powers
Google Chrome. Node uses an event loop and consists almost entirely of asyn-
chronous non-blocking API's, making it a good fit for streaming applications such
as those built using Comet or WebSockets.
Search WWH ::

Custom Search