Douglas Crockford on Becoming a Better Programmer with Style

 

Here is some of my coverage of the 2012 Silicon Valley Code Camp at Foothill College in Los Altos, California where I was reporting for Dice and Dice News.

“[Programming] style is the part of the program the compiler ignores,” said Douglas Crockford, known to many programmers as the Guru of Javascript. Crockford laughs and said he sees himself more as a mahatma. We spoke at the 2012 Silicon Valley Code Camp at Foothill College in Los Altos, California.

While style is personal taste, it can have a critical influence on your error rate. And reducing your error rate will make you more productive, said Crockford.

“Qualities that you want to look for in a programming style are things which will help make your programs more perfect,” said Crockford who developed a program called JSLint which reads all his programs and tells him what he’s getting wrong.

As for how programmers can find their style, Crockford offered this thought exercise: “Think of a bug as being a needle in your program. If you want to be able to find them easily you need to make your program look less like a haystack.”

I tried to get Crockford to explain monads to me, for which all he could explain is that they’re an idiom that can be used in higher order programming. The failure to articulate, explained Crockford, is that once someone understands what a monad is they lose the ability to explain it clearly.

For other advice on style, Crockford recommends a very dated book, Elements of Programming Style by Brian Kernighan and P.J. Plauger. While the book hasn’t aged well because the languages referred to in the book were Fortran and PL/I, the principles on style are still good and hold up today, he said.

Tags: , ,