Node.js has been around long enough to have achieved adoption by some major players (LinkedIn, Yahoo!, and Netflix), but is still young enough to be cause for concern for your typical corporate middle manager. Its been a driving force behind creating a more sophisticated JavaScript, as well as the only safe place one can then use the newly improved scripting language. And, since turnabout is fair play, the cutting-edge JavaScript has now become the driver for a newly revamped Node.js organization and release paradigm.
Node.js has also redefined what we do with JavaScript. Nowadays, an employer is just as likely to demand that JavaScript developers work in a server environment as well as the more familiar browser environment. In addition, Node.js has created a new server language thats generating attention from Ruby, C++, Java, and PHP server-side developersespecially if they also know JavaScript.
To me, Node.js is fun. Compared to so many other environments, it takes little effort to get started, create and host an application, and try out new things. The scaffolding necessary for a Node project just isnt as complex or pedantic as whats required for other environments. Only PHP has as simple an environment, and even it requires tight integration with Apache to create outward-facing applications.
As simple as it is, though, Node.js has bits that can be hard to discover. It is true that learning Node.js requires obtaining a mastery of its environment and the core APIs, but its also about finding and mastering these hard-to-discover bits.
Who This Book Is For
I see two audiences for this book.
The first audience is the developer who has been creating frontend applications using a variety of libraries and frameworks, and who now wants to take their JavaScript skills to the server.
The second audience is the server-side developer who wants to try something new or needs to make a shift to a newer technology. Theyve worked with Java or C++, Ruby or PHP, but now they want to take the JavaScript theyve picked up over time, and their knowledge of the server environment, and merge the two.
These are two seemingly separate audiences with one shared knowledge: JavaScript, or ECMAScript if you want to be more precise. This book does require that you are very comfortable working with JavaScript. Another commonality is that both audiences need to learn the same Node basics, including the core Node API.
However, each audience brings a different perspective, and skills, to the learning experience. To enhance the usefulness, Ill work to incorporate both perspectives into the material. For instance, a C++ or Java developer might be interested in creating C++ Node add-ons, which might not be interesting to the frontend developer. At the same time, some concepts like big-endian may be very familiar to the server-side developer but unknown to the frontend person. I cant dive too deeply into either viewpoint, but I will work to ensure that all readers dont end up frustrated or bored.
One thing Im not going to do is force rote memorization on you. Well get into the core module APIs, but Im not going to cover every object and function, because these are documented at the Node website. What Ill do instead is touch on important aspects of each core module or specific Node functionality I think is essential in order to, hopefully, give you a baseline so you can hold your own with other Node developers. Of course, practice makes mastery, and this book is a learning tool. Once youre finished with the book youll need to continue on for more in-depth explorations of specific types of functionality, such as working the Mongo-Express-Angular-Node (MEAN) stack. This book will give you the grounding you need to branch out in any of the many Node directions.
Speaking of Node Documentation
At the time this was written, other Node developers and I were involved in discussions about issues associated with the Node.js website. Among them was defining the current version of Node.js, which is what should be documented when one accesses the documentation.
When last I joined the discussion, the plan was to list all current long-term support (LTS) versions of Node.js in the /docs page, as well as the most current Stable release, and to provide an indicator for Node documentation versions on the top of each documentation page.
Eventually, the documentation people would like to generate version diffs of the API for each page, but thats going to be a challenging project.
At the time this book was published, Node released Node.js 6.0.0 as the Current release, and abandoned Stable as the designation for the active development branch. Node.js 6.0.x will eventually transition into the next LTS release.
Because of all these versions, when you do access documentation of APIs at the Node.js website, always check to make sure the documentation matches your version of Node.js. And it doesnt hurt to check newer versions to see what new thing is coming your way.
Node.js Is Node
The formal name is Node.js, but no one uses it. Everyone uses Node. End of story. And thats what well be using, for the most part, in this book.
Book Structure
Learning Node is a back-to-basics book. Its focus is on Node, and the modules that make up the Node core. I do lightly touch on some third-party modules, and provide extensive coverage of npm, of course, but the primary goal of this book is to bring you, the reader, up to speed on basic Node functionality. From this solid platform, you can then move in other directions.
includes an introduction to Node, including a brief section on how to install it. Youll also get a chance to take Node out for a spin, first by creating the web server listed in the Node documentation, and then by creating a bit more advanced server using the code I provide. In addition, Ill also touch on creating Node add-ons, for the C/C++ coders among you. And what would an introduction to Node be without an overview of the history of this environment, which issued its first release as 4.0 rather than 1.0.