Tuesday, August 14, 2007

Horse Asses are 80 Columns Wide

When I was younger my dad told me a story - which I deign to say sounds somewhere between half- and un-true (as most of his stories tended to be). It went something like this:

When designing the first rockets, early engineers had to consider transportation along the ground to their destinations. They chose to make the boosters half the width of the road so they could be loaded onto a truck and transported after manufacturing.

Trucks - as it were - are limited to the width of the road and were originally built to be of similar width to train tracks, which until the advent of automobiles were the only long-distance terrestrial transport available and a spacing-unit comfortable to those who manufactured the first cars and roads.

Trains and carriages were of a similar width - having descended from old European standards which were based on their roads which were patterned after the roads first carved out by the Roman Empire.

The Roman roads were little more than solidified paths which were packed by the grooves made by chariots - which of course were merely the width of two horses.

The punchline of the joke was something like "This goes to show that engineers just follow the horses asses that came before them."

Good story, eh? Its truthfulness notwithstanding - it makes a good point. I have a term for it - I call it "trimming the ham". Since I already have my slippers and pipe, and you, nestled by the fireplace in love-worn jammies, I'll spin another yarn.

There were once two college roommates, preparing their first big meal out in the world on a crisp fall day. Like any intelligent and innocent country girls, they decided that a ham would make a super-duper centerpiece to their array of delicious and healthful accouterments: baked beans, salad and cornbread. Before placing the ham in the pot, the sweet, amateur cook took a large knife and proceeded to cut the ends off - safely of course.

Her roommate - a curious girl with golden locks and a chocolate brown complexion inquired innocently: "What the fuck are you doing?"
"That is how you cook a ham. You trim the ends off before cooking."
"That's fucking crazy. I've never seen that shit," she replied coyly.
"Watch your fucking mouth," the cook suggested.
"Fuck you!" The golden-hair girl objected.
"Fine - I'll call my mom and we'll settle this. I bet 20 bucks I'm right."
"You're on, bitch!" Goldilocks agreed to the proposal.

So they skipped off to the public phone where the girl with golden braids and the cook called home.
"Hey mom, is that you?" She said into the phone. "Shut the hell up Sissy, and put mom on the phone you little brat!" she added, cheerily.
"Mom - you cut the ends off of your ham, right?" pause, "OK, so you do?" The black girl with the golden hair frowned. "I see - grandma does it that way too? Uh huh... she is a great cook... OK... yeah, thanks mom - bye... Please send money," she added with love.

The ham chef beamed with pride and informed her lovely roommate that, "You see? I told you, I fucking told you... now give me my twenty bucks."
"Listen," she nodded, "Your mom, you, even your granny are all nuts."
"Twenty... dollars," she repeated, ready for her congratulations.
"OK - enough of that shit," Goldie interjected. "Let's call your Granny - I gotta know what's wrong with your family."

So back to the phone the happy chef turned - this time to ring her loving grandmother. This time, she held the phone up so both could hear.

Ring ring... ring ring... ring ring

"Old people," she said with familial pride, "sleep all the goddamn time." Eventually the phone picked up.
"Hi Granny!" She shouted courteously
"Oh hello Deary! You know, I was just talking about you the other day to Mildred, you remember Mildred, right? Well - you know what her grandson is doing..."
"Sounds good Granny," she interjected, "Hey, I have a cooking emergency I need some help with."
Grandma cooed on the other end of the line.
"You cut the ends off of hams, right? Mom said you did."
Grandma laughed, "Oh dear - I haven't done that in years! I don't do that anymore."
The cooks grin and Goldie's frown switched places. "Why not?"
"I have a larger pan now. You see, Dear, I cut the ends off to fit in my old small pan."

Did you enjoy that? I hope so... a modern classic if I say so myself (which I don't). The moral is quite clear, though - "because it's always been that way" is no excuse to continue doing stupid things. Find out why, then adapt to new circumstances. Common wisdom - it seems to me - is rarely very wise.

Do I have a point? Sure. 80 column width programming. Stop. Please, oh please, for the love of Jesus Helguera (Google it) stop adhering to this outdated standard. I have worked with - oh, about 25 different programming teams over the years - and a disturbing majority are obsessed with that 80 column thing. It made sense back with old fixed-width displays, it even made sense a few years ago when people coded via telnet+vi. But not anymore. I hear the same damn arguments: but what if someone needs to connect and edit code in a terminal? You want to know my answer? Fuck 'em. It's 2007 - even terminals can stretch further than 80 column width anymore. Besides, why let those highly unlikely, exceedingly rare situations dictate standards? All editors these days can scroll right or autowrap - only retards and Satanists code remotely. Seriously... all non-trivial projects should have version control. Check out the damn code. If you find yourself modifying code via ssh+emacs (et al), you're probably modifying live code which is punishable by defenestration in some circles.

I'd rather a line be a single operation, even if it is 300 columns long (I have a 23 inch cinema display... are you a professional programmer? yeah, then you should too) even if I had to scroll. If you are a halfway decent coder those rare long lines should be far and few between - making the rest of your code more readable overall.

"But Eric, I travel a lot and have to code on my tiny laptop." Yeah, me too, but most people don't. Don't you care about them, you selfish punk? Please, think of the children.

I just started a new job last week, and I see a weird mix. Some lines are 150 columns wide, and some are broken into max 80 column chunks. Why?


Of course, that whole thing fits on my screen - but even if it didn't at least I know it's one operation. Now if you'll excuse me, I need to find my medication.


Jonathan said...

Studys have shown that it is easier on the eyes to track a shorter line than a long one. This is why newspapers and magazines print in columns.

Coding is the same way. If I'm going to stare at the same code all day (which I do), I want to minimize the amount of eye tracking I do.

What does this mean? I don't want to move my eyes more than the 18" or so that my LCD is wide. A larger display, means more lateral eye movement, which leads to fatigue.

And that is why you adhere to 80 character lines.

Eric said...

Wrong, Jonathan. Studies show that it is easier to _read_blocks_of_text_ when the lines are shorter (like articles or books). There are no studies that I know of that carry that over into coding.

Modern code, by nature, produces jagged lines. I don't advocate shoving code into tight little blocks - just that the occasional really-long-line is easier to read than a five line block of tight code that does a single logical step.

Thanks for reading.

zeekay said...

Apple geeks once again prove to the world that the only way to do anything...is on apple equipment. BECAUSE IF YOU DON'T HAVE A 23 INCH CINEMA DISPLAY YOU AREN'T HIP. Seriously, I have a 23 inch (viewsonic) display, and long lines still look as fucktarded as when I view them on my 15.4 inch laptop screen.

P.s. I maintain a dozen websites, and I do 90% of my coding with ssh+nano. I should probably do everything on one of my local test servers, but it's so satisfying to edit the code remotely, and then bam! Refresh and instant gratification. (and vi? come on man, I quit using that in the 90's)

But hey, I don't know 23 languages so obviously you > me.

Jonathan said...

Eric, if you find that your line of code is over 80 columns, you can probable either rewrite it for brevity (which I don't like, because I prefer verbose code), or you can do what I do, and simply indent the next line over.

Its easy to follow, and you don't make anyone have to scroll.

I think that despite code having different lengths, when properly indented, it follows a distinct pattern, and a long like is a lot like a outlier statistic on a bar graph., ugly, annoying and useless.

Eric said...

Wow sheesh. I try and be funny and where does it get me? Man, who knew calling people "retards and Satanists" could be so inflammatory?? Live and learn, I guess (for those who are slow - that, too, was a joke).

zeekay - I just plain don't believe you. No one who knows "23 languages" keeps such meticulous count. It's like freshman in college who claim "I drank 19 beers last night LOL!" No you didn't - real drinkers don't keep track. I honestly have no idea how many languages I know. Moreoever - who said anything about Macs? I just so happen to use a Cinema display - the point was: anyone who codes for a living owes it to themselves to have a huge monitor... increased screen real-estate is a huge timesaver. Finally... Nano over VI? Seriously?

jonathan - I agree. I never said anything like "all j00r code shuud B 1 line LOL!!" Actually, I said "If you are a halfway decent coder those rare long lines should be far and few between". Obviously you can refactor - and I encourage it.

runeb said...

Not all languages are suitable for wrapping on column 80, but there should certainly be a styleguide-imposed maximum right-margin.

The combination of a right-margin and good linewrapping rules ensure that code looks similar all through the codebase. Failing to understand why this is a good idea, is truly the mark of a newbie.

Eric said...

Newbie, eh? My buddy Jim and I have spoken about this at great length... we call it the "curve is a circle" theory. I direct you to this:


Hm... maybe I'll writeup my own take on this phenomenon.

The Peer said...

I agree with everything apart from what you said about autowrap. I want to see all the code, not just the first bit of each line. Sometimes important characters occur after column 80 (or whatever)... I can still keep track of the beginning of each line because of its indentation.

I'll tell you what bugs me even more than hand-wrapped code - CSS that's written like this:

p {
word-wrap:for retards;

The simplest stylesheet ends up hundreds of lines long, and if you're hypersearching for "font-weight:bold", all you get is a bunch of lines which - you've guessed it! - say "font-weight:bold", with absolutely no context to figure out which one you were actually looking for.

One statement per line, in CSS terms, translates as:

p { font-weight:bold; color:pink; ... word-wrap:for retards }

(and no ugly, unnecessary trailing semicolon)


Eric said...

Granted - I probably went too far on the autowrap thing. That's beyond style to personal preference... you know, it's hard to stop a good rant ;)

OK - I officially retract the autowrap statement.