Douglas Crockford
108
Crockford: Yeah, I think they got it right. Their initial style is right.
Particularly in JavaScript. JavaScript does semicolon insertion, and so there
are places where the meaning of a program will change in a drastically bad
way if you put the braces on the left instead of on the right. It turns out the
K&R style is not subject to that problem, but the flush style is.
So I can argue in the case of JavaScript, there absolutely is a correct way of
placing the braces. In other C-flavored languages I can’t make that same
case. Some people like to have their braces flush and I’ve seen people argue
for hours about which way is right, and none of the explanations make any
sense on either side, because what they’re really arguing is, what I used in
school, or what I used at my first job, or the style that’s used by someone
who impressed me, now looks right to me and everything else looks wrong.
It’s similar, I suppose, to an argument about, should we be driving on the left
side of the street or the right. Ultimately there’s not a good case for doing
it one way or another. If you live on an island, you can do it the wrong way
and it doesn’t matter, but ultimately the community benefits if we can all
figure out how to drive on the same side.
Seibel: So if you changed jobs and went somewhere where they
programmed C or Java in a different style than you prefer, would you say,
“Well, I’ll switch and I know that after a little bit, I’ll be happy to see this
style”? Or would you just not take the job?
Crockford: Maybe that’s something that people should look at—what is
the house of style here? Are we on the left or the right? And maybe not go
work at a place that gets them on the wrong side. It does take on a Dr.
Seuss quality where you get really upset about whether you’ve got a star on
your belly or not. Ultimately you have to embrace the house style and you
hope that the people who put the house style together knew what they
were doing. They probably didn’t; maybe it doesn’t matter. It’s more
important that everybody be on the same page.
Seibel: So when you’re reading code you start with a typographical
cleanup, how deeply or dramatically do you refactor things?