If you don’t use JavaScript and not interested in learning it, you can stop reading now.

What always disappointed me in books on JavaScript is the fact that authors seldom separate JavaScript from Web programming. Thus, most books on JavaScript provide the description of features (syntax, built-in objects) and then jump to DHTML, DOM, AJAX and JavaScript libraries, producing a thousand-page tome.

The impression that one can get from these books is that JavaScript looks much like Java but doesn’t have “proper” inheritance, though the latter can be emulated. There is even a book which exercises in implementing GoF patterns in JavaScript.

JS the Good PartsA notably different view on JavaScript is presented in a recent book by Douglas Crockford called “JavaScript: The Good Parts”. The first difference is that it’s just about JavaScript itself. The second difference, implied, is the size of the book—it’s just about 150 pages, so you can grasp it in a weekend.

The most outstanding difference, though, is that it describes JavaScript as “Lisp in C’s clothing”. In fact, it is. As JavaScript’s designer Brendan Eich recounts, the language was initially designed as a functional one with Self-ish prototypal inheritance, and it was wrapped in Java-like syntax due to Java’s positioning as a language for the Web, back in middle 1990-s. If you are interested, here is a link to Mozilla’s CVS with experimental JavaScript implementation in Common Lisp.

So, Douglas explains JavaScript from this very point of view, in somewhat different way. As an example, he advocates against the common practice of using the new operator for creating new objects. Why? Because if you forget to specify new, the code will still “work”, producing hard to debug invalid behavior. And how properly create new objects then? Read the book!

Personally, I deal with JavaScript since 2001, mostly using it as an application scripting language. And, nevertheless, I discovered lots of new stuff in this small book. Apparently, most of book’s material flies around in the Web, I just was too lazy to pick it up. But I think, most of us are.

Advertisements