Jon said:
Well, one of the reasons I believe K&R became popular was because it
was used in books - and in books, vertical space *is* a relatively
precious commodity. People copy what's written in books, and thus a
tradition is born...
Personally, I don't know much about K&R's coming into being, but it's
interesting to note that Linus Torvalds states the rationale of using
K&R bracing style in the Linux source code as: "K&R", but goes on to say:
"Also, note that this brace-placement also minimizes the number of empty
(or almost empty) lines, without any loss of readability. Thus, as the
supply of new-lines on your screen is not a renewable resource (think
25-line terminal screens here), you have more empty lines to put
comments on."
http://pantransit.reptiles.org/prog/CodingStyle.html
Sure, Linus most likely didn't invent this bracing style, but I'd bet
that he's influenced many a person with his work ;-)
Also, in my opinion, the K&R bracing style makes C-like code more
similar to code from other languages that don't have the flexible block
begin/end markers that C has. Consider the following BASIC code:
If Something Then
DoSomething
Else
DoSomethingElse
End If
This is more equivalent to:
if (something) {
DoSomething();
} else {
DoSomethingElse();
}
.... than:
if (something)
{
DoSomething();
}
else
{
DoSomethingElse();
}
Due to this, I'd imagine that K&R would feel somewhat normal to BASIC
programmers who are picking up a C-like language.