Learning Node – A good how-to guide for server-side Web development with Node.js – #programming #bookreview

Learning Node
Shelley Powers
(O’Reilly, paperbackKindle)

 “Node is designed to be used for [server-side] applications that are heavy on input/output (I/O), but light on computation,” veteran Web technology author Shelley Powers notes in Learning Node, her ninth and newest how-to book from O’Reilly.

“Node.js,” she explains, “is a server-side technology that’s based on Google’s V8 JavaScript engine. It’s a highly scalable system that uses asynchronous, event-driven I/O (input/output), rather than threads or separate processes. “It’s ideal for web applications that are frequently accessed but computationally simple.”

I’ve criticized some previous Node books (1) for assuming that all of their readers know a lot about Node.js and assorted programming languages and (2) for not giving enough step-by-step installation and start-up information.

Happily, Learning Node is well written, nicely illustrated with code samples and screen shots, and assumes only that you have some working familiarity with JavaScript. It gives a detailed overview of how to set up development environments in Linux (Ubuntu) and Windows 7. “Installation on a Mac should be similar to installation on Linux,” the author adds.

One caveat regarding code examples: “Most were tested in a Linux environment, but should work, as is, in any Node environment.”

The 374-page book has 16 chapters. The first five “cover both getting Node and the package manager (npm) installed , how to use them, creating your first applications, and utilizing modules.”

Shelley Powers notes that she incorporates “the use of the Express framework, which also utilizes the Connect middleware, throughout the book.” So if you have little or no experience with Express, you will need to pay attention to chapters 6 through 8. But: “After these foundation chapters, you can skip around a bit,” she adds.

Some of the additional chapters cover key/value pairs, using MongoDb with Node, and working with Node’s relational database bindings.

Two chapters get into specialized application use. “Chapter 12 focuses purely on graphics and media access, including how to provide media for the new HTML5 video element, as well as working with PDF documents and Canvas,” the author points out. “Chapter 13 covers the very popular Sockets.io module, especially for working with the new web socket functionality.”

The final chapters are crucial, particularly if you want to move from learning Node to working in a production environment. Chapter 14 covers “Testing and Debugging Node Applications.” Chapter 15 “covers issues of security and authority…it is essential that you spend time in this chapter before you roll a Node application out for general use.”

Meanwhile, Chapter 16 describes “how to prepare your application for production use, including how to deploy your Node application not only on your own system , but also in one of the cloud servers that are popping up to host Node applications.”

Learning Node is both an excellent overall introduction to Node.js and a how-to reference guide that you will want to keep close at hand as you develop and deploy Node applications.

Si Dunn

For more information: Node.js, paperback, Kindle

Node for Front-End Developers – Writing server-side JavaScript applications – #bookreview #in

Node for Front-End Developers
By Garann Means
(O’Reilly, paperback, list price $14.99; Kindle edition, list price $7.99)

Node is a JavaScript platform used to create server-side applications, communicate with the client, work with data, create dynamic web pages, and handle other tasks.

According to the Joyent Incorporated’s nodejs website: “Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”

Node’s library has many modules created by developers who have focused on automating server-side development. But Garann Means’ new, 45-page book shows how you can get started programming for back-end servers using Node and JavaScript.  

Node.js is easy to download.  And, according to Node for Front-End Developers: “Node is easy to set up or very easy to set up. Node runs on Unix-compatible systems and, more recently, Windows.”

The how-to-get-started instructions, however, are a bit sparse in this thin book, and virtually nonexistent for Windows. Beginners who don’t have much experience with JavaScript may puzzle over a number of basic “What now?” and “WTF?” issues. 

Sparse information for Node beginners, however, is not limited to Node for Front-End Developers. I checked several other sources of  Node documentation and found similar problems. You’re just supposed to know this stuff, I guess. 

As one example, I followed the book’s instructions to create Node’s important package.json file, then discovered that what I had downloaded from Nodejs already contained a package.json file. In fact, it was now in several subdirectories. Was I supposed to edit it, instead? Delete it and replace it with my file? Had I just screwed up the installation by creating my own file?

After a lot of horsing around with node and npm at the command line and getting strange results at the not-quite “Hello World” level, I happened across a small note on the GitHub.com website. It stated that Node’s “Windows builds are not yet satisfactorily stable but it is possible to get something running.”

Especially if you resort to package managers to help you out.  And maybe get assistance from a Node guru. [See UPDATE below.]

Yes, I was indeed attempting a Windows setup, and I did get Node to partially work. But after several tries at reinstalling, rebooting, debugging, and attempting to supplement the book with conflicting bits of  information downloaded from the web, I gave up having “fun” with Node. (UPDATE: Recently, I reviewed my command line procedures a bit, looked again at my files and subdirectory structure and tried again. This time, Node works fine at the “Hello, World” level and beyond. I stand by my criticism that this book’s how-to-get-started instructions should be made clearer for Windows users. But I am at fault, too, for not figuring out what I was doing wrong much sooner.)  

Your results likely will be much better than mine, especially if you have more than novice experience with JavaScript.  and are using something other than (and better than?) a Windows machine. 

As for Node for Front-End Developers, the rest of the book appears to be an easy-to-use guide to getting a basic understanding of the Node platform. The code examples look good and are preceded by well-written explanations. I have now tested some of them successfully and plan to try a few of the longer, more-complex examples soon. wish I could have tested more of them. But I intend to keep this book and try Node again once easier and more stable Windows options are available.

The book’s chapters are:

  • Chapter 1, Getting Node Set Up
  • Chapter 2, Serving Simple Content
  • Chapter 3, Interaction with the Client
  • Chapter 4, Server-Side Templates
  • Chapter 5, Data Sources and Flow Control
  • Chapter 6, Model-View-Controller and Sharing Code

How-to-get-started instructions are vital in any programming and developer’s book, in my view. And they need careful preparation and presentation for every major operating system that is supported.

Countless beginners are looking for new programming and development paths and challenges, and many of them will buy books that are beyond their experience level so they can try to learn faster and backfill as they go. Most of them also won’t have the latest-and-greatest hardware and software. Therefore, minimum requirements need to be spelled out clearly, as well.

Don’t let my blunderings with Windows dissuade you from considering this book. Node has been hot, and if you have JavaScript experience at the browser level, Node for Front-End Developers can help you learn how to work on back-end servers, too.

It pays to be versatile in today’s fast-paced tech world.

But yeah, I probably do need a Mac and a Linux machine flanking my Windows PC.

#

Si Dunn is a novelist, screenwriter, freelance book reviewer, and former software technical writer and software/hardware QA test specialist. His latest book is Dark Signals, a Vietnam War memoir available soon in paperback. He also is the author of a detective novel, Erwin’s Law, a novella, Jump, and several other books and short stories.