The C Programming Language

The Assembler, Fortran, Snobol, Cobol, PL/1, and Pascal books are all gone, but I still have this one, “The C Programming Language,”   by Kernigan and Ritchie, affectionately known as “K & R.”

And I just want to say one thing about it, and that is, there are a lot of different indentation styles, but when it comes to server-side programming languages, I for one do not care for the “K&R braces” style.  It’s not consistent!

Servers and Browsers

When it comes to server-side languages like C, PHP, and Java, I prefer the Allman Style, and it’s nice to know I am not the only one.  White space and consistency are important!

However, when it comes to browser-side code — and CSS: I am looking at you — I find myself using the K & R style. This is, of course, because there is very little need to nest CSS, and hence no need for the ambiguity (and I admit it is very slight) we see in their book.

Java and JavaScript

At first this left me in a bit of a quandary when it comes to everyone’s new darling, JavaScript. Because JS works hand-in-hand with CSS, it’s only natural to follow the same policy.

So for S&G I started using the K&R-style braces on some JS. I hereby admit that it is working well!

For one thing, I am learning it does indeed have some appeal when working on large projects. This is because we typically have many windows open so real estate is at a premium.

And for another, most, if not all, text editors and IDEs these days make it easy to find pairs of matching parentheses. So wake up to find out that consistent vertical alignment of braces is no longer of high importance.

Mixing Styles

Moreover, using both styles this way actually has a bit of an advantage, because it is immediately and glaringly obvious whether I am working on server or client code. My plan is to continue using this hybrid policy, at least until I start using Node.js, anyway….