Node.js in Action

Authors: Mike Cantelon, Marc Harter, TJ Holowaychuk & Nathan Rajlich
Publisher: Manning
Pages: 416
ISBN: 978-1617290572
Audience: Advanced JavaScript programmers
Rating: 4
Reviewer: Ian Elliot

Node.js is just another way that JavaScript seems to be eating the world. Does an "In Action" book explain the how and why?

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 is the main problem that books on Node.js have to overcome. Either they can present you with the simple idea - it's an asynchronous server side JavaScript - and finish in about three pages or they can attempt to tackle some of the difficulties that this simplicity creates. Of course, these difficulties are more or less what you encounter using JavaScript to do any reasonably large task on the client side. 

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.

So essentially this book is about a little bit of theory about how Node.js works and then a whole lot of looking at the various libraries that give you things like templating, storage and ways of organizing your project. Most of the chapters spend a lot of time in examples and explaining how to do things. You need to be a reasonably good JavaScript programmer to get anything at from these explanations and you also need to understand the client side fairly well - HTML, CSS and clientside JavaScript programming.

 

Banner

 

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.

 

Nodejsinaction

 

 

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. 

 

Banner


Functional Design (Addison-Wesley)

Author: Robert C. Martin
Publisher: Addison-Wesley
Date: September 2023
Pages: 384
ISBN: 978-0138176396
Print: 0138176396
Kindle: B0CGHQKGYG
Audience: General
Rating: 4.5
Reviewer: Kay Ewbank

This book sets out to explain the principles, patterns and practices of functional design, and why functional prog [ ... ]



The Art of WebAssembly

Author: Rick Battagline
Publisher: No Starch
Date: May 2021
Pages: 304
ISBN: 978-1718501447
Print: 1718501447
Kindle: B08TSYXJTS
Audience: WebAssembly developers
Rating: 5
Reviewer: Ian Elliot
WebAssembly is the coming thing - or so we are told.


More Reviews

 

Last Updated ( Wednesday, 05 February 2014 )