Chapter 1. About Node
Node is an exciting new platform for developing web applications, application servers, any sort of network server or client, and general purpose programming. It is designed for extreme scalability in networked applications through an ingenious combination of server-side JavaScript, asynchronous I/O, and asynchronous programming, and is built around JavaScript anonymous functions, and a single execution thread event-driven architecture.
The Node model is very different from common application server platforms that scale using threads. The claim is that, because of the event-driven architecture, the memory footprint is low, the throughput is high, the latency profile under load is better, and the programming model is simpler. The Node platform is in a phase of rapid growth, and many are seeing it as a compelling alternative to the traditional—Apache, Java, PHP, Python, Ruby on Rails, and so on—approach to building web applications.
At heart it is a standalone JavaScript virtual machine, with extensions making it suitable for general purpose programming, and with a clear focus on application server development. The Node platform isn't directly comparable to programming languages frequently used for developing web applications, and neither is it directly comparable to the containers which deliver the HTTP protocol to web clients (Apache httpd, Tomcat, GlassFish, and so on). At the same time, many regard it as potentially supplanting the traditional web application development stacks.
It is implemented around a non-blocking I/O event loop and a layer of file and network I/O libraries, all built on top of the V8 JavaScript engine (from the Chrome web browser). The I/O library is enough to implement any sort of server implementing any TCP or UDP protocol, such as, DNS, HTTP, IRC, or FTP. While it supports developing servers or clients for any network protocol, the biggest use case is in regular websites in place of a technology such as an Apache/PHP or Rails stack, or to complement existing websites. For example, adding real-time chat or monitoring to existing websites can be easily done with the Socket.IO library for Node.
This book will give you an introduction to Node. We presume that you already know how to write software, are familiar with JavaScript, and know something about developing web applications in other languages. We will dive right into developing working applications and recognize that often the best way to learn is by rummaging around in working code.