04 December 2012

JavaScript: The Good Parts

Overview

There are a few challenges and a lot of criticism has been made when it comes to writing decent JavaScript code.

Outside of the valid reasons to complain about JavaScript, like the incoherent type system, the root of most of the problems is often trying to turn JavaScript into another language by using it as such and failing to see it for what it really is.

This pamphlet proposes a subset of the JavaScript language to those who are already familiar with the syntax and it promises to make your life easier when both having to write and maintain JavaScript code.

Eradicating confusions

The author starts out by trying to get the main confusions about the language out of the way.

I rarely encounter that many railroad diagrams in order to learn a programming language but I have to admit that they were proven helpful to that extent.

There also are insights into what makes Javascript confusing and what can be done about it by addressing all of the issues taking examples from his own experience. Since there seems to be many different ways to accomplish the same thing, there’s an attempt at showing you the better way to do things.

What you should do

The author cycles through what he thinks are the good parts and provides examples on how to use them. These illustrations are concise and self-explanatory and the code examples often accompanied by diagrams.

The programming style proposed in this book is different then most of what is proposed in other books about JavaScript. For one, it throws away the pseudo-classical style in favour of prototypical inheritance style that is built in JavaScript which you can readily leverage using more appropriate patterns then the ones we’re often more accustomed to when we think about OOP.

In other words, it makes you think about object creation and relationships in a different manner that what you may be used to in order to be a more effective JavaScript programmer.

What you should avoid

Using the bad parts in JavaScript is akin to the historically bad GOTO.

When reading the appendix, you get to learn about the awful and the bad parts of JavaScript which are not surprisingly the portions of the language that you should avoid. At least, there are reasons provided as to why you should avoid those parts so you can decide for yourself if his arguments are convincing enough for you to start changing your coding style or not.

Verdict

I would definitely read this book again and I have! It’s also a nice addition to The Definitive Guide.

More!

Crockford works at Yahoo, YUI Theater put out a few series that turned out to be very interesting while covering everything in this book and even more.

An Inconvenient API: The Theory of the DOM

Advanced JavaScript

Douglas Crockford/Javascript The Good Parts <iframe width="480" height="360" src="//www.youtube.com/embed/_DKkVvOt6dk?rel=0" frameborder="0" allowfullscreen></iframe>

Douglas Crockford/The JavaScript Programming Language

There also an excellent series on Youtube covering many things from the history of the language and how it came to be what is is today



blog comments powered by Disqus