Learning Node by Shelley Powers; O’Reilly Media


Learning Node by Shelley Powers is timely, and should be on the reading list of every JavaScript and server-side developer. I have used Node on Linux for x86 and ARM, and Windows. Its performance, especially for network-intensive applications, has me astounded.

I’ll briefly delve into things that stood out to me in each chapter of the book.

Chapter 1 is must read if you don’t understand the asynchronous nature of Node. It also covers building it from source for Linux, and using WebMatrix to develop and run Node applications with IIS.

Chapter 2 shows how to use command line REPL (read-eval-print loop) to quickly test code, inspect objects, and as an editor. Imagine that!

Chapter 3 covers the Node core objects and modules. In particular, the global namespace object, process.nextTick to asynchronously execute a callback, util.inherits to implement inheritance, and EventEmitter to emit events.

Chapter 4 covers the Node module system. Covers require and how it searches for modules (.js, .node or .json), delete require.cache to reload a module from source, how to create your own custom module, and expose its objects and functions using export. It also covers often used modules such as npm (installed with Node) for package management, Optimist for options parsing, and Underscore.

Chapter 5 delves deeper into the asynchronous nature of Node, covering control flow, exception handling, and asynchronous patterns. It then discusses the Step and Async modules that implement those patterns. It also briefly discusses Node coding style.

Chapters 6, 7, and 8 discuss web development middleware and frameworks such as Connect and Express, and templating modules that work in tandem with Express, such as EJS and Jade.

Chapters 9, 10, and 11 discuss the different means of persisting data, in a key-value store such as Redis, document-centric database such as MongoDB, or a relational database such as MySQL, either directly or using the Sequelize ORM.

Chapter 12 discusses manipulating PDF by executing external tools such as PDF Toolkit, creating drawings using the canvas module, and streaming videos.

Chapter 13 discusses the popular Socket.IO library that you can leverage for bidirectional communication between server and the Browser.

Chapter 14 discusses unit testing, acceptance testing, and performance testing. Tools and modules covered include Apache Bench (ab), nodeunitSelenium, and soda. Also discussed is the nodemon module that can be used to restart the application when a script is changed.

Chapter 15 discusses TLS/SSL and HTTPS for securing data communication, saving password as hash using the crypto module, authentication using the passport module, and authentication with Twitter using the passport-twitter Passport strategy module. It also discusses writing secure code by avoiding eval, validating data using a module such as node-validator, and running external scripts in a sandbox using the vm module.

Chapter 16 discusses deployment of applications to a server, or to the various cloud services such as Azure (using Cloud9 IDE), Joyent, Heroku, Amazon EC2, and Nodejitsu. It discusses modules such as Forever to recover from crashes, and integration with Apache. The discussion on clustering with Node is very brief and does not discuss the experimental cluster module.

I am glad the author took the time to write this book, I am a better “Noder” because of it. I’d like to thank O’Reilly Media for giving me the opportunity to review this book as part of the blogger review program.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s