Foreword by Brendan Eich

Brendan Eich, creator of JavaScript

In April 1995 I joined Netscape in order to “add Scheme to the browser.” That recruiting bait from a month or two earlier immediately morphed into “do a scripting language that looks like Java.” Worse, because the negotiation to put Java in Netscape was underway, some at Netscape doubted that a “second language” was necessary. Others wanted to build something like PHP, an HTML templating language for a planned server-side offering called LiveWire.

So in 10 days in May 1995, I prototyped “Mocha,” the code name Marc Andreessen had chosen. Marc, Rick Schell (vice president of engineering at Netscape), and Bill Joy of Sun were the upper-management sponsors who supported my work against doubts about a “second language” after Java. (This is ironic since Java has all but disappeared in browsers, while JavaScript is dominant on the client side.)

To overcome all doubts, I needed a demo in 10 days. I worked day and night, and consequently made a few language-design mistakes (some recapitulating bad design paths in the evolution of LISP), but I met the deadline and did the demo.

People were amazed that I’d created a language compiler and runtime in less than two weeks, but I’d had a lot of practice over the decade since switching from a physics major in my third year to math/computer science. I had always loved formal language and automata theory. I’d built my own parsers and parser generators for fun. At Silicon Graphics, I built network-monitoring tools that included packet-header matching and protocol description languages and compilers. I was a huge fan of C and Unix. So knocking out “Mocha” was really a matter of sustained application and concentration.

Sometime in the fall of 1995, Netscape marketing renamed Mocha “LiveScript,” to match the LiveWire server-side product name. Finally, in early December 1995, Netscape and Sun concluded a trademark license, signed by “Bill Joy, Founder” on behalf of Sun, and LiveScript was renamed JavaScript (JS).

Because of the LiveWire server plans, in the first 10 days I implemented a bytecode compiler and interpreter as well as a decompiler and runtime (the built-in JS objects and functions we know today: Object, Array, Function, etc.). For small client-side scripts, bytecode was overkill, but the LiveWire product included the feature of saving compiled bytecode for faster server-app startup.

Of course, Netscape’s server-side JavaScript offering failed along with most of the rest of Netscape’s business, as Microsoft tied Internet Explorer (IE) into Windows and entered the server markets into which Netscape was trying to diversify from its browser market, where commercial users who had once bought browser licenses no longer paid since IE was being bundled with Windows for free.

So in spite of LiveWire’s failure, even in 1995 we could see the appeal of end-to-end JavaScript programming. Users saw it too, but this history is known only to a relative few today. And LiveWire made a fatal error that Node.js avoided: it embraced blocking input/output and a process-mob model on the server side…so it did not scale well.

Fast forward to the 2009’s JSConf EU, where Ryan presented Node.js. I was gratified to learn of Node and to see how well it realized the end-to-end JavaScript vision, especially how it wisely built in nonblocking I/O from the roots up. Ryan and core folks have done a great job keeping the core small. Isaac and all the module owners have built an excellent module system to relieve pressure on the core, so it doesn’t grow too large. And the Node community that has evolved around the code is excellent, too.

The result is a really productive, fun system for building servers, to complement the increasingly productive, fun JavaScript client side and to facilitate code reuse and coevolution. Without Node, JavaScript would be still associated with its birthplace, the overconstrained client side of the Web, with the much-maligned Document Object Model and other historical accidents looming too large. Node helps JavaScript by freeing it from its limiting client-side patrimony.

This book nicely conveys the spirit of Node and the knowledge of how to use it well to build interactive web apps and sites. Node is a blast, and Node: Up and Running is a fitting guide for it. Enjoy!