Chapter 1

Getting Started


An old programming adage says that while functionality is an asset, code is a liability.

本書を通し Node.js の乗りこなし方を身につけるに当たって、次のことを念頭に置いてください。コードにおいて一番素晴らしい一行は、書く必要がないために書かなかった一行です。書かずに済むのなら、そうすべきです!

Throughout this book, as you learn to harness Node.js, keep in mind that the best line of code is the one you never had to write. If you can get something for free, take it!


However, the nature of a technical book is to teach you how to do something, even if somebody has already done it for you. By understanding how things work, you’ll be better able to build on top of them.

ですから、基礎的なところから始めて段階的に進んでいくことにしましょう。まずは Node.js の基盤に近いところから始めていきます。Node.js の環境、言語、原理的な API についてです。これらへ習熟するにつれて、他の人が書いてくれた module や、ライブラリ、サービスを使う方法を学んでいくことになります。それができるようになったら次のレベルに進みましょう。

So we’ll be progressing in stages. In the beginning, you’ll be working at the lowest levels of Node.js — getting to know the environment, the language, and the fundamental APIs. As you master those, you’ll learn how to use other peoples’ modules, libraries, and services to replace some of that code and go to the next level.


By the end, you’ll see where it’s possible to make great gains using existing libraries, and where it makes sense to implement the functionality yourself. At the end of the day, this wisdom is the power that will distinguish you from a novice developer.

Thinking Beyond the web

A lot of the buzz around Node.js is focused on the web. In truth, Node.js serves a bigger purpose that people often miss. Let’s use a map to see where Node.js fits in the broader scheme of things. Imagine the set of all possible programs as the inhabitants of a vast sea. Programs that have similar purposes are near each other, and programs that differ are further apart. With that picture in mind, take a look at this map. It shows a close-up of one particular outcrop in this sea, the Island of I/O-Bound Programs. I/O-bound programs are constrained by data access. These are programs where adding more processing power or RAM often makes little difference.