2 INTRODUCTION
Taking back control of the web server, as you’ll see, resulted in a new category of applications
being developed on top of Node.JS: real time web apps. Very fast data streaming between a
server and thousands of concurrent clients is common currency in Node. is means that not
only are you going to be creating more ecient programs, but you’ll be part of a community
that’s pushing the boundaries of what we thought was achievable in the web world.
With Node, you are in charge. And with that capability comes a set of new challenges and
responsibilities that this book carefully examines.
APPROACH
First and foremost, Smashing Node.JS is a book about JavaScript. Your knowledge of JavaScript
is absolutely required, and therefore I dedicate an initial chapter to the concepts of JavaScript
that, in my opinion and experience, matter most.
As you learn later, Node.JS strives to create an environment where the browser developer feels
comfortable. Common expressions that are not part of the language specication but were
added by browsers instead, such as setTimeout and console.log, are still available in
Node.JS to this end.
Aer you make it past the “memory refreshing” phase, you go right into Node. Node comes
with a lot of useful modules as part of its core, and a revolutionarily simple package manager
called NPM. is book teaches you to build things leveraging only the Node core modules,
and then a selection of the most useful abstractions the community has built on top of it, that
you can install with NPM.
Before we jump into a module designed for solving a specic problem, I usually try to go
through the hurdles of solving the same problem without them rst. e best way to under-
stand a tool is to understand why the tool exists in the rst place. erefore, before you learn
about a web framework, you’ll learn why it’s better than using Node.JS HTTP primitives.
Before you learn how to build an app with a cross-browser real time framework like Socket.
IO, you’ll learn the limitations of barebones HTML5 WebSockets.
is book is all about examples. Every step of the way you’ll be building a small application or
testing out dierent APIs. You can execute all the code examples in this book with the node
command, which you can use in two dierent ways:
◾ rough the node REPL (Read-Eval-Print Loop). In the same spirit as the Firebug or
Web Inspector JavaScript consoles, this approach allows you to type in some JavaScript
code, press Enter, and get it executed, right from your operating system’s command-line
interface.
◾ As les that are run through the node command. is approach requires that you use a
text editor, which you obviously already have. I personally recommend vim (http://vim.
org) for this purpose, but any of them are good.