Learn to build fast and scalable software in JavaScript with Node.js Node.js is a powerful and popular new framework for writing scalable network programs using JavaScript. This no nonsense book begins with an overview of Node.js and then quickly dives into the code, core concepts, and APIs. In-depth coverage pares down the essentials to cover debugging, unit testing, and flow control so that you can start building and testing your own modules right away. If you already know JavaScript and are curious about the power of Node.js, then this is the ideal book for you.
I had a blast using this book as a guide to exploring the Node ecosystem!
Once you get past the short chapters in Parts I (installing, overview) and II (modules, buffers, events, and timers), then it's time to have fun!
This book is full of tiny working example programs. I absolutely fell in love with creating tiny little web servers, TCP chat programs, etc. In fact, I really can't remember when I last had so much fun learning a new programming environment.
Even just creating some wee little file streaming examples was fun. I remember thinking, "Man, this is fun actually making things work in a couple lines of code. I've been out in the real world too long!"
In the real world, you have to deal with real-world problems. Users doing unexpected stuff. Servers doing unexpected stuff. Software blowing up. Hardware blowing up. Networks blowing up. People blowing up. Browsers, browsers, browsers. After a while, you kinda start to forget why you love this stuff so much in the first place. This reminded me.
Working with front-end JavaScript development for a while, I was already used to asynchronous, callback-driven program flow. So using the same methods on the server felt natural to me. But it didn't take long, working through this book's examples, for me to realize just how much of Node development involves callbacks. Good lord, you practically have to pass a callback function when you update a variable.
I don't feel like Teixeira had too much sage advice for dealing with the huge numbers of callbacks. He clearly explained the problem and the available solutions: using named functions rather than inline anonymous functions, writing your own home-brew flow control function (excellent example!), or using an existing flow control library such as Async.js. But while all of these solutions are certainly better than an enormous page of indented callbacks, they all involve painful amounts of housekeeping (error handling - I'm looking at you!). I feel pretty confident we'll eventually see some really great syntactic sugar to help reign this in.
I love the fact that Teixeira has a chapter on testing. The examples are clear and demonstrate testing asynchronous functionality. This is the one area where I admit I'm still behind the curve. I want to get to a point where I can't imagine not writing test cases for my libraries and applications.
Following along with the book, I got to play with a lot of different 3rd party libraries for Node. Many of these have changed since this book was written. I always made sure I was using the latest libraries and changed the example source to work with the new APIs. It was rarely difficult. A lot of the libraries had clearly-documented migration guides. Most changes involved just a couple method name changes.
I really enjoyed using the Connect middleware library for Node's HTTP server. Express (another layer of functionality built on top of Connect) impressed me less, but probably because it feels like more of a framework than Connect does, and I'm really not a fan of frameworks.
I absolutely loved Socket.IO and building the example WebSocket chat application was probably the most fun I had with the entire book. I built something that felt like a really slick little application - and it was so easy!
I always modify book examples as I transcribe them and run them. I do this for a number of reasons: first, it lets me know that I really understand what I'm writing; second, I often don't care for the author's methods and want to see if I can do better; third, I have tons of fun and learn more when I add functionality and improve on the application; and fourth and finally, I do it because it lets me take ownership of the code - what's the point of all that typing if I'm not making something of my own?
For example, I added a "Connecting..." box on the WebSocket chat application which changes to "Connected" with a green background when the application is able to connect to the Socket.IO library on the server. Simple and effective (and really easy to do with Socket.IO's client-side library!)
I mention this because I did not like the example applications Teixeira used for the last two chapters about CouchDB and MongoDB. Both examples added database support to previous example applications from earlier in the book. The CouchDB example built upon the Socket.IO chat application. The MongoDB example built upon the Express.js HTTP web application.
These were the two largest examples applications we'd built thus far. I had made numerous changes to both examples both for fun and to use the most current versions of both libraries.
Both DB chapters contain pages and pages of example application code. I feel like the subject we're trying to learn gets buried in all of that.
The MySQL chapter (using the node-mysql library) was completely self-contained and I much preferred it.
Despite the chapter I didn't care for, I'm still really excited to learn CouchDB. After doing some reading, I've decided that I'll use it as my database in a littl personal project I'll be building with Node. I found the CouchDB: The Definitive Guide O'Reilly book, which is completely free online, so I'm going to use that as a supplement to this book's CouchDB chapter.
As for MongoDB, I decided I would create my own assignment. So I used the Mongoose docs (the Node.js MongoDB library), the MongoDB Getting Started guide, and various docs for Connect middleware - specifically bodyParser (built-in) and Dispatch to create a tiny toy MongoDB blog website application.
The entire application came to just 50 lines, including the inline HTML page(s)! I've posted it as a Github Gist here.
In all, I had tons of fun with this book and I learned lots of new things, including some non-Node technologies I'd never actually tried before.
Some of the examples could have been better or could have been explained in more detail, but there's nothing you can't work out for yourself - especially in this age of copious online information. I also came across a few errors in the text, but nothing that gave me any trouble or impeded my understanding of the subject.
My motivation for reading this book was simple. I needed a technology that would allow me to build backend as quickly as possible. There were 2 candidates for that: Ruby on Rails and Node.js. I’m not very proficient with Ruby, because of that learning a JavaScript-based technology was the most obvious choice for me.
The book is great. It’s neither small nor large. It has a perfect size of 4 hundred pages that can be easily digested throughout the week. Every chapter has an introductory for those who hadn’t an experience with technology it tells about. I was kinda amused with such small pieces of text about UDP and TCP. I’ve forgot a lot about the basics of what I usually do.
The book is full of small but useful examples from the real life. If you’ll cram through the book at a stallion pace (as I did) for the end of the week you would be able to build a small but full functional websites and back end systems using node.js&REST&NoSql. I did it as a hackathon project for less than 5 hours.
This is an excellent introduction to node.js programming. It assumes basic familiarity with javascript, thankfully, allowing the book to focus on node-specific packages, programming, and conventions.
The book is pretty well organized, with most chapters presenting the development of a node application. I found the chapter on web sockets especially interesting - this is something long overdue in web applications, and node has excellent support for the feature.
The node runtime model is pretty interesting: a single-threaded event-driven model in which there are no blocking api calls. This avoids most of the problems of multi-threaded applications while still providing a high level of concurrency.
The book concludes with three chapters on database interfaces in node. And that brings up one of the few criticisms I have of the book: I had the sense that the publisher wants great big thick books, so having three separate chapters about three database was just the ticket.
But the size and format of the book was not the author's fault, and the content was useful.
My major complaint is about the number of errors in the book, both in the text and in the printed code. Again: I blame the publisher for this. If you're going to take 85% of the book's revenues you really need to take some responsibility for copy editing and, sadly, this publisher simply failed.
Buon manuale introduttivo a Node.js, anche se l'avrei organizzato diversamente. A parte una breve introduzione sull'installazione, oltre 150 pagine vengono dedicate ai vari componenti del framework, in un modo un po' troppo astratto.
Finalmente nella parte 5 (capitolo 20) viene presentata un'applicazione di esempio, che viene spiegata molto bene e passo per passo.
La parte 6 (connessione ai DB) è molto sbilanciata verso MongoDB, mentre il capitolo su CouchDB è un po' ridotto, e quello su MySQL quasi inesistente.
Forse è vittima della velocità di crescita dell'ecosistema di Node.js. Nonostante sia un libro pubblicato meno di due mesi fa, tratta argomenti già vecchi (la versione 2 di express, mentre è già uscita la 3 che presenta alcune novità sostanziali, come la gestione dei template di pagina nei motori di templating). Probabilmente al momento in cui è stato scritto molte librerie non erano ancora stste scritte o abbastanza diffuse.
Consigliato per avere un'idea e una buona panoramica su molte funzionalità di base, ma da prendere con le pinze per la compatibilità.
This book is indeed a blessing for newbie web developers like. Pedro explains what, why and how of Node.js in detail.
The only drawback I see is, the advanced sections like developing app using Express.js are outdated. The book user v2.5 where as current version is v3.4.
great book with good examples. covered the material well. I have already developed in node before reading and still learned a good amount. I obviously suggest the newer version, but I found this historically rewarding. Processes and streams were the most interesting parts. I'm used to promises and async now so remembering the event loop was humbling.