JavaScript Programming Style and Your Brain
Written by Ian Elliot   
Sunday, 30 October 2011

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.

 

dcrockford

 

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.

More information

JSHint - the (gentler) JavaScript code quality tool

JSLint,The JavaScript Code Quality Tool

 

To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Twitter or Facebook or sign up for our weekly newsletter.

 

Banner


Looking Forward To NAO 7
03/11/2024

Introduced to the world in 2004 by its creator Bruno Maisonnier the kid-sized, autonomous humanoid robot NAO, turns 20 this year. At less than 2 ft tall, it is small in stature, but plays a big r [ ... ]



Gifts For Geeks 2024
22/11/2024

Are you ready for Thanksgiving, when overeating remorse and a surfeit of being thankful causes the unsettling thought that there are only four weeks till the Xmas break? So here is a mix of weird [ ... ]


More News

<ASIN:0596517742>

Last Updated ( Sunday, 30 October 2011 )