|Node.js in Action|
Authors: Mike Cantelon, Marc Harter, TJ Holowaychuk & Nathan Rajlich
Node.js has come from nowhere to almost global domination in what seems like a few months. It is a very simple idea that has lots of complex consequences.
This book attempts to cover a the wide range of things that you might use Node.js for by going over the difficulties of building an asynchronous server that starts off with just the bare facility to send an HTTP packet. To get from here to the sorts of facilities you find in a typical webserver you have to do a lot of work. Or rather, you don't because you simply make use of libraries to do the job.
Part 1 of this book starts off with a look at Node fundamentals. It goes fairly slowly though the idea of non-blocking code on the client side and then explains that its just the same on the server side. As someone else said "Node.js is just like onclick" - which is true enough.
After you have the basic idea that Node.js is mostly asynchronous, Chapter 2 takes you into a big application. If you don't like books that present you with ideas using big examples you aren't going to get along with this one. It takes its "in action" title fairly seriously. For me the big example of a chat room was difficult to follow; it uses ideas not really introduced at this point such as sockets, which are discussed in depth in Chapter 13.
More successful is Chapter 3, and I suggest you skip to it if the example in Chapter 2 doesn't work out for you. This discusses modules which are fairly easy to understand, and then dives into the central issue of using Node.js - managing asynchronous flow of control. It does a good job of explaining the low level problem, but then just passes the solution to the Nimble library without really explaining it or the alternatives. It would have been nice to read something about promises or similar approaches to asynchronous flow. A bigger omission is that it doesn't explain how to deal with iteration or conditional execution of asynchronous tasks and it ignores error handling.
Part 2 of the book is about web application development. Chapter 4 introduces the HTTP server object - which as a central Node.js object is a bit late, but the emphasis isn't on the basics but on issues such as using REST, forms and HTTPS. Next we move on to storing data - MySQL, Redis, MongoDB and Mogoose but only a few pages are devoted to each. The next two chapters are about using Connect middleware and the two following ones are on using the Express Framework. This is essentially where Node.js grows enough additional software to start to look a bit more like a web server.
Chapter 10 deals with testing Node and it is basically a general look at unit testing. The final chapter of the section is on templating using EJS, Mustache and Jade. All great as long as you want to use these frameworks.
Part 3 of the book is called "Going Further with Node". This consists of three chapters mostly about deploying and hosting Node applications. Chapter 12 is mostly about using Git, cluster and general configuration issues. Chapter 13 looks at alternative ways of handling web app communications - sockets, TCP/IP and interacting with the operating system. The final chapter is something general about the Node ecosystem - online resources, GitHub and npm repositories.
So is this a good book on Node?
As long as you want lots of code then it probably is. For me its approach was a bit too fragmented to present a clean "this is what you need to do" storyline. It was very difficult to see the bigger picture in among all the different libraries and approaches.
Overall the book got better as it progressed which suggests that it is better suited to the advanced user. If you already know Node.js then this might well be a good addition to your toolkit, but if you are a beginner trying to see what the fuss is about - probably not.
|Last Updated ( Wednesday, 05 February 2014 )|