All posts by Tom H

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….

My First Code Review

My second job was writing IBM Mainframe Cobol programs for the City of Richmond.

I started out making some changes to some existing programs: enhancements and bug fixes, nothing major.  We had Systems Analysts then who were familiar with how the programs worked and who would spec out the changes quite thoroughly.

Then I got to write my very first entire program.  I was so proud of it!

During this time I’d identified a couple of colleagues as being sharper than the rest (mainly because the were not part of any of the gossip gangs).  So I asked them what they thought of my program, hoping that they would like it, because I had learned at my previous job that maintainability is important.

They tore my little program to pieces.  I thought I might cry — but I didn’t.

They taught me how to use structured programming techniques to organize my code.  Many mark Edsger W. Dijkstra’s famous paper GoTo Statement Considered Harmful as being the beginning of structured programming techniques, but it is much more than using Perform statements instead of GoTos.

Because it strives to read like English, Cobol does not have the syntactical mechanisms that many other languages do, control structures that allow developers to break things down and organize code into components.  So they showed me how to precede all functions with three- or four-digit numbers, that would reflect the function’s place in the flow of logic.  Although foreign to me at first, after seeing how it worked, it made a lot of sense.

As it turns out, I learned more in that hour than I did in many of my classes at school!