Free Chapter from Douglas Crockford’s “JavaScript: The Good Parts”

May 5, 2008 at 7:51 am by Eric Miraglia | In Development |

Click through to read Ch. 5 of Douglas's forthcoming book.The #2 book on Amazon’s JavaScript shelf this morning is Douglas Crockford’s forthcoming Javascript: The Good Parts (currently available for preorder and due for release later this month). In this volume, Douglas articulates a philosophy of coding in JavaScript that builds up on and extends the content of his popular video series and articles. The premise, as Douglas puts it: "Most programming languages contain good parts and bad parts. I discovered that I could be a better programmer by using only the good parts and avoiding the bad parts."

Douglas and his editors at O’Reilly were kind enought to let us offer a sneak preview of JavaScript: The Good Parts here:

Here’s how Douglas opens the discussion of inheritance in JavaScript:

Inheritance is an important topic in most programming languages.

In the classical languages (such as Java), inheritance (or extends) provides two useful services. First, it is a form of code reuse. If a new class is mostly similar to an existing class, you only have to specify the differences. Patterns of code reuse are extremely important because they have the potential to significantly reduce the cost of software development. The other benefit of classical inheritance is that it includes the specification of a system of types. This mostly frees the programmer from having to write explicit casting operations, which is a very good thing because when casting, the safety benefits of a type system are lost.

JavaScript, being a loosely typed language, never casts. The lineage of an object is irrelevant. What matters about an object is what it can do, not what it is descended from.

JavaScript provides a much richer set of code reuse patterns. It can ape the classical pattern, but it also supports other patterns that are more expressive. The set of possible inheritance patterns in JavaScript is vast. In this chapter, we’ll look at a few of the most straightforward patterns. Much more complicated constructions are possible, but it is usually best to keep it simple.

Click here to keep reading (1.2MB; PDF).

Thanks to Laurel Ackerman and Simon St. Laurent at O’Reilly for the permission to share the sample chapter.

Share and extend: Bookmark with Yahoo! My Web | Bookmark with del.icio.us | digg it! | reddit!

8 Comments »

RSS feed for comments on this post. TrackBack URI

  1. I admit, I think I have a nose bleed reading that one chapter. Though Crockford’s articles and videos are amazing! Looking forward to seeing the dead tree version.

    Oh! And thank you for the treat. I certainly will be going back home to marinate over this one today.

    Comment by Raju — May 5, 2008 #

  2. Hats off to Douglas Crockford for putting out so much good info on Javascript. He’s one of the only authors on the topic that I’ve gone out of my way to read.

    I’ll be buying this book the first chance that I get.

    Comment by Jeremiah — May 6, 2008 #

  3. […] Free Chapter from Douglas Crockford’s “JavaScript: The Good Parts” » Yahoo! User Interface Bl… (tags: javascript lazycoder tutorials) […]

    Pingback by links for 2008-05-06 | Lazycoder — May 6, 2008 #

  4. […] YUI blog today, there is a free chapter of Douglas Crockford’s JavaScript […]

    Pingback by JSPatterns.com » Blog Archive » Doug Crockford on inheritance — May 6, 2008 #

  5. […] Новая книга дугласа Крокфорда Доступна для бесплатного скачивания одна из глав новой книги Дугласа Крокфорда «Javascript: The good parts». В этой главе подробно объясняются принципи наследования в языке Javascript. PDF версия доступна для скачивания на сайте YUI blog. […]

    Pingback by Новая книга дугласа Крокфорда | АяксЛайн.ру — May 6, 2008 #

  6. I ordered this book last week, can’t wait to read it. If anyone out there is looking to learn JavaScript, I HIGHLY recommend the following books:

    JavaScript: The Definitive Guide
    David Flanagan

    Professional JavaScript for Web Developers
    Nicholas C. Zakas

    I also want to point out that Nicholas Zakas is part of the Yahoo crew and I’m not kissing any ass. I ordered and read the book before I knew that (at the time he wrote the book, it stated he worked back east). It’s a very good book.

    I also have the following book on my to buy list:

    Pro JavaScript Design Patterns
    Ross Harmes and Dustin Diaz

    No doubt a kick ass book from those two.

    Comment by matt h — May 7, 2008 #

  7. […] an epiphany for me this past week. Credit for laying the foundation for this moment goes to the sample chapter on Inheritance of Douglas Crawford’s new book, JavaScript: The Good Parts. I did not understand […]

    Pingback by Rule52 » How YUI’s event listeners changed the way I write JavaScript — June 1, 2008 #

  8. […] event listeners changed the way I write JavaScript", bringing together insights from the sample chapter of Douglas Crockford’s JavaScript: The Good Parts and the expressive power of Adam Moore’s YUI Event […]

    Pingback by In the Wild for June 20 » Yahoo! User Interface Blog — June 20, 2008 #

Leave a comment

Note: Comments are moderated for first-timers. Spam deleted.

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Hosted by Yahoo!

Copyright © 2007 Yahoo! Inc. All rights reserved. Privacy Policy - Terms of Service

Powered by WordPress on Yahoo! Web Hosting.