With JavaScript under heavy attack by Google, among others, this video, of a talk given by Douglas Crockford at HTML5 Dev Conference 2011, is timely and important.

With JavaScript under heavy attack by Google, among others, this particular video is timely and important - but perhaps not for the reasons you might expect.

It is a video from the HTML5 Dev Conference 2011 of a talk by Douglas Crockford titled "JavaScript Programming Style and Your Brain".

After some vague philosophical musings the real core of the talk starts at about 5 minutes in with a discussion of why JavaScript has bad parts and how JSLint will help you only use the good parts. There then follows a discussion of what constitutes good style in JavaScript. In this case style isn't about aesthetics and self expression but about how to write code that isn't error prone.

The main thesis is:

"If there is a feature of a language that is sometimes problematic, and if it can be replaced by another feature that is more reliable, then always use the more reliable feature."

If you accept this idea then the next is obvious - use JSLint to enforce those replacements.

None of the ideas are new, especially if you have read his book JavaScript the Good Parts.

Even if you don't view the whole video, watch the question and answer session at the end (about 31 mins in) for a put down of languages that compile to JavaScript, why JavaScript is great and what Crockford thinks of JSHint, the forked code quality tool.

Quite a lot of the talk is about ideas that apply to any language and you can't really argue with many of the general points. You can, however, take issue with some of the recommendations but if you do try to think about the general objectives before you make a final decision.

I have to admit that the arguments are put so persuasively I have changed my mind on using a particular construct that I had long ago decided was safe as long as you understood it.

So, at the end of the day, is JavaScript a bad language?

Its crimes appear to be a few sloppy and potentially error-prone constructs which are very easy to avoid.

Is this really all that is wrong with JavaScript?

The bottom line is that the problem with JavaScript is minor as long as you accept it on its own terms. On the other hand, if you really want it to be a class-based, object-oriented language with all the dangers that entails then - yes JavaScript has a real big problem. But another way of saying this is that JavaScript is not Java.