This is another Packt review, and this time , its a book titled “Mastering NodeJS”, this might be my biggest review so far because this book packs a lot of information. I hope you read and enjoy the review on the book.

Chapter 1 : Understanding the NodeJS Environment

The chapter starts with the motive and concept behind NodeJS, it highlights the current situation about current technology and how NodeJS can solve existing issues such as the ability to scale and efficiently serve multiple connections without bottlenecks. A few notes also, on why the adoption of JavaScript  was selected as the language to power NodeJS. It also covers other important and essential topics such as Events and Modularity(seperating code files), this two topics sums up the pattern through which NodeJS Applications are written, and also touches on the Modular Pattern adopted “CommonJS” and the famous packaging system NPM (Node Packaging Management). The author goes deeper to touch on the Google V8 (JavaScript Engine built in C++) and Harmony, however this topics are a bit advanced to beginners but nevertheless but still readers should at least get to know the internals, it concludes the chapter with the explanation of the “Process Object” and the REPL (Read Eval Print Loop) aka NodeJS Shell.

Chapter 2: Understanding Asynchronous Event-Driven Programming

This is arguably no doubt one of the most important and longest chapter in this book, and it deserves to be; as Asynchronous Event-driven Programming is a bit different from other pattern of programming especially coming from a Blocking environment like PHP. The chapters requires a careful read and also this will serve as a reference point due to its complexity. The chapter dives into the asynchronous pattern used in writing NodeJS applications and explains the various concepts around it. The “EventEmitter”'s role will be explained in this chapter, Signals and Forking (creating child processes) are also explained in a detailed manner. A lot of useful tools are really explained here and especially the most important part “Event Loop”. My personal advice is to read this chapter repeatedly so as to get a good grasp.

Chapter 3: Streaming Data Across Nodes and Clients

This chapter covers the various interfaces needed for the abstract Stream. It covers the readable Streams, publishing,pulling,writable streams and Duplex streams,the author shows how an HTTP Server can be created in node and send data to the client, personally if you are using NodeJS for web applications, you might want to spend a lot of time looking at this chapter. It covers a lot on the Request Object; and using the Query String to parse GET variables from the URL, handling of POST Data, setting of cookies, Responses and writing to HTTP headers.

Chapter 4: Using Node to Access the FileSystem

This chapters givers a history and overview of the file system, and the interface that NodeJS provides to enable you write data easily and also manipulate file information systems. The author was kind enough to throw some important foundation knowledge such as how UNIX treats files. As usual numerous examples are carefully constructed to introduce you to various types of operations ranging from “reading from directories,reading files,creating a writable stream, file operations and also handling file uploads”. By the end of the chapter; the reader would gain a lot of information about NodeJS and accessing and writing to files and streams.

Chapter 5: Managing Simultaneous Connections

This chapter talks mostly on concurrency and multiple connections, it talks about the C10k problem, the design architecture of a network that handles 10,000 simultaneous users. In this chapter the author will break down the principles of concurrency and also parallelism. This is the first chapter that introduces Third Party libraries; it talks about managing routes with Express ; a popular NodeJS Framework and Redis an in-memory database. It covers other topics such as authentication,session,cookies and handshakes.

Chapter 6: Creating Real Time Applications

This chapter focuses on the development of a real time application , and it covers the following by touching 3 different approaches AJAX, WebSockets and SSE (Server Sided events). This chapter also provides codes and the type of real time application that can be built for collaborative purposes. In this chapter you will be shown how to build a similar Google Doc- like application and how others can edit it. However I would advise for readers to take time to practice with an idea of a collaborative simple application to gain more experience.

Chapter 7: Utilizing Multiple Processes

Chapter 7 speaks about achieving parallelism, and working with numerous processes, it also sheds light on both the pattern of Single Thread programming and Multi-Threaded and explains the complexity behind Multi-threading such as thread synchronization. This chapter really goes deep by giving a detailed explanation behind Multi-threading and also the project “libuv”, a C++ project that is based on asynchronous programming and event-driven pattern. You will be introduced to the ChildProcess object which is responsible for spawning (creating) processes, with this you can fork a  child process to run a task such as invoking the terminal to get PHP information or running a python script and returning the result into NodeJS, you can supply command and arguments. What's more interesting is that, when a parent forks a child processes, the child process can communicate with the parent object and vice -versa. This chapter is highly detailed and interesting.

Chapter 8: Scaling your Application

Building your application is half of the job, scaling become an issue especially when the application becomes extremely popular, in this chapter the authors explains a lot of topics ranging from Network latency,HOT CPU and others. The readers will also be introduced to tools to monitor performance and memory usage, such examples being the AB Apache Bench, a popular tool used for benchmarking web application and simulating HTTP Requests. A lot of tools and services are covered in this chapter.

Chapter 9:Testing your Application

NodeJS just like any other environment has certain tools to enable you ensure your application performs in the intended manner, luckily with the advent of NPM (NodeJS Package Manager) testing in NodeJS is quite easy. This chapter iterates on the principles behind testing and types of testing to be made. e.g such as Unit Testing, Functional Testing , Integration Testing. It also covers native debugging tools provided by NodeJS and covers the two terms “Errors” and “Exceptions”. The author covers testing a NodeJS application using the following tools : ZombieJS, Mocha,Grunt and PhantomJS

Appendix A : Organizing your Code

Simply put this chapter talks about using NPM and the style/manner in which NodeJS modules are installed. It covers guides on code organization and how you can share your repository with others. Remember someone out there might need your module.

Appendix B : Introducing the Path Framework

This chapter introduces the Path Framework to the user and gives reasons why users should adopt the framework for NodeJS Development.

Appendix C : Creating your own C++ Addons

This chapter covers how you can create your own C++ add-ons and expose them through the NodeJS header file. This chapter might be a bit complex to users with no C++ knowledge therefore a good knowledge on C++ and OOP would be essential.

Conclusion

Basically the book is no doubt a very detailed book that manages to cover complicated issues and shed lights on lots of principles and paradigms over the choice of selected patterns used in NodeJS Application. Mastering NodeJS is quite a read,  as it really broke down the architecture design of NodeJS, its event-driven programming style and good insights over why certain style of coding are adopted in NodeJS. This book will cater to users new to NodeJS, who want to go beyond the basic use of Nodejs and master the framework and understand why NodeJS operates the way it does. Personally I would recommend users to understand JavaScript and some important topics such as Callbacks and Closures, and also this book would require a lot of coming back to; to enable users grasp the framework and what it has to offer. Overall its a real good read and got to understand some new things and concepts.

About the Author

Sandro Pasquali began writing games on a Commodore PET in grade school, and hasn't looked back. A polyglot programmer, who started with BASIC and assembly, his journey through C, Perl, and PHP led to JavaScript and the browser in 1995. He was immediately hooked on a vision of browsers as the software delivery mechanism of the future. By 1997 he had formed Simple.com , a technology company selling the world's first JavaScript-based application development framework, patenting several technologies and techniques that have proven prescient. Node represents for him only the natural next step in an inevitable march towards the day when all software implementations, and software users, are joined within a collaborative information network. He has led the design of enterprise-grade applications for some of the largest companies in the world, including Nintendo, Major League Baseball, Bang and Olufsen, LimeWire, and others. He has displayed interactive media exhibits during the Venice Biennial, won design awards, built knowledge management tools for research institutes and schools, and has started and run several startups. Always seeking new ways to blend design excellence and technical innovation, he has made significant contributions across all levels of software architecture, from data management and storage tools to innovative user interfaces and frameworks. He now works to mentor a new generation of developers also bitten by the collaborative software bug, especially the rabid ones.

Visit the link