Originally published by Robert Beisert at fortcollinsprogram.robert-beisert.com

Patterns: Leave the defaults alone

Fun fact: more than a few code conventions are inspired by the fact that everyone’s computer is set up differently.

Problem 1: Non-standard tab spaces

The standard UNIX/Linux tab standard is 8 spaces. That means that, to create a similar spacing to the default tab, you would have to hit the space bar eight times. This standard embraces the binary underpinning of computers, and it creates effective spacing comparable to a seven-character variable and a space.

However, for one reason or another, people have been changing that standard value.

I’ve seen everything from 2 spaces to 7 spaces (although no one seems to go over 8), but rarely do I see anyone employing the default tabs.

This makes it harder to write “pretty” code, because notation that lines up nicely on one machine looks chaotic on another machine.

Of course, you could always destroy your space bar to avoid tabs altogether, but I argue it’ll never be worth it. At worst, it makes your code harder to modify without being really obvious, and at best it takes time that you could spend anywhere else.

Besides, if you need to reduce the tab size to make your code fit on the line, you probably need to seriously reevaluate your coding practices.

Problem 2: Aliasing

Most beginning programmers are unaware that the UNIX/Linux systems allow you to assign an alias (new name) to a function or set of commands. These are stored in the system instead of in a code file.

The problem here should be obvious: the other guy’s computer lacks your alias.

This usually trips up programmers when they are helping out a friend, only to find that their aliases don’t work.

Generally speaking, don’t use aliases unless you can comfortably operate without them.

Problem 3: Other

There are any number of customization options on machines these days, and most of them are harmless. At the end of the day, it usually doesn’t matter to me whether the machine has a GNOME, X, or KDE environment. I can even work with VI when someone’s fiddled with all the highlighting options.

However, when you start fussing with anything non-standard (libraries, programs, etc.) , you make it harder for everyone else to replicate what you’re doing. In a corporate or open-source sense, that’s disastrous.

The Solution: STANDARDS

I’d argue that the best standards are usually those that come with the system, but there are other ways to make it work.

  • Issue everyone the same distribution, with standardized libraries and all
  • Make everyone work off of virtual machines, which are synched on a daily basis
  • All agree to a standard
  • Work in terminals without access to the variables required to change the standards

Personally, I’m not a fan. Just make sure that your scripts clearly dictate what non-standard programs and libraries they require, and we should all be fine.

And don’t change the tab space. 8 is great: 4 is poor.

Lesson: Standards allow everyone to stay on the same page.

photo by: