Death to the Space Infidels!

@Jayson P: What if you use an editor and not an IDE? :slight_smile:

If you find yourself in a disagreement about coding standards, its time to rewatch the oracle scene from The Matrix again. See how the spoon bends.

(btw captcha is still orange)

The best of both worlds:

Now we just need product support…

We just went through this where I work last week, but our discussion was more around some people not using indention at all! Very hard to read their code. So I would be happy as along as it was indented in some way shape or form.

@fschwiet: captcha has always been orange

today’s IDEs take care of this problem, and you can’t tell the difference between tabs or spaces anyway

I personally like Spaces… but over the years I’ve gone from 3 spaces (which I was instructed to use by a professor) to 4 space since I thought it looked cleaner, to 2 spaces (since 4 spaces makes it hard to print code sometimes)… the problem is now I have code with a mix of the three… hence now, I’m moving to TABS. TABS work great in that most popular editors have preference settings related to how many spaces to use when representing a TAB, this way if one developer likes to look at it with 2 spaces and another with 4… the TAB is displayed to the developers liking. Yes this makes my VIM screen a bit hard to use at times… but that is only since I haven’t taken the time to set my preferences there yet.

however, using spaces is a dumb waste of time

Just wait until your code gets double-spaced because revision control is configured incorrectly…

As I started reading this article, I was amazed at the huge gulf between the insignificance of this issue compared to the huge significance of the ethical standards in this codinghorror post:

Then I finished reading the article. Now I think this issue is important. I’m so confused. sniff

On the bright side, its nice to have had my perspective changed about something so early on a Monday morning. What a great way to start the week.

Seriously. If you use spaces, you’re telling everyone else in your team how they should see the code. If you use tabs, they can decide, with their editor of choice, how to see the code.

Personally I like a 2 char wide indent. I realize that isn’t enough for some people. Tabs solve that problem!

Using spaces is like hard coding syntax highlighting directly into the document. Evil!

Of course I only have a preference with the initial indentation. If you’re trying to make comments line up at the end of several lines of code you’re doing it wrong.

I really wish the IDE would just abstract out the formatting so it looks to me like i want and to you like you want. (For langs where whitespace doesnt matter that is). Hell, that concept could even be moved to variable names.

The only programming project with no disagreement whatsoever on code formatting is the one you work on alone.

Unless you work alone on the same project for several years. Then you’ll be cursing the idiot who wrote this poorly formatted crap several years ago. And have only yourself to blame.

You can usually control with your IDE the size of a tab, but you cannot adjust the size of 4 spaces. A tab is just an abstraction that says ‘indent one level’ and leaves it up to you to decide what an indent means.

Spaces are almost like hardcoding values in your code.

I used to use tabs. I still do, but have vi expand them to 4 spaces. Because a guy I was working with liked Emacs, and he was using 4 space tabs too, but my real, saved tabs looked like 8 in Emacs.

Of course if you want to be green (all the rage these days, until the taxes kick in), a tab takes 1 byte, and spaces take as many as you’ve defined tabs to be, so you’re using extra disk space w/o tabs. And when you fill disk, you need another one = more power. When you read file, you have to read more bytes = more CPU, more physical memory, more energy usage. Then again, expanding tabs takes CPU power too…

Oh, woe is me. Nah, really I could care less.

A more fundamental issue is the one of how a function opening should be declared. Old hands will tell you that you put the function return type on one line, and the function name on the next (in column 1). Because that makes it real easy to find the function declaration vs. a mere invocation of the function. But so many people use these fancy programming environments that they don’t care. Many of them don’t even know how to use a decent text editor. They think nedit is state-of-the-art, when in fact nedit is about as powerful as M$'s notepad.

And they are helpless without the aid of really bad colors showing them what’s a string, what’s a function, etc.

As a vi aficionado, it irritates me that the latest vim has stupid features to cater to the lowest common denominator. Auto comment continuation is OK, but why make that the default? Colors are OK (not for me), but make that an option they have to turn on if they need that kind of hand-holding. I’m about ready to return to nvi or the original ATT vi to get away from the bloat-ware that vim is becoming.

I have seen young people use they up-arrow key 15 times to find a previous command that was 5 characters in length. Like retyping a command is hard. Or using the search feature inherent in every command line shell (other than anything from M$).

Sigh. I guess I am getting old and cranky.

  1. The Tab key is a quick way to enter a specific number of spaces. Most ‘decent’ editors will substitute the spaces for you, so your document doesn’t actually contain any tab characters. (If you like tab chars stored in your programs, print a big C program that has tabs in it.

  2. Jeff’s professor was right, 3 is the correct indent size. Two ain’t enough, and four’s too many. Besides, 3 fits exactly under
    If xxxx.

As a senior software lead, I can personally attest to spending many hours doing nothing but code cleanup…out of self-defense!

Why do I say self-defense? Because I know damn well that I’m responsible for getting the product out the door. And when it’s 2:30 in the morning on the deadline day, the LAST thing I need is to discover a crash bug in a piece of code that:

  1. wasn’t written to the company’s coding standard.
  2. was written with variables like a and f everywhere.
  3. mixes tabs and spaces to such a degree that it’s simply not possible to line up anything at all.
  4. has been hacked upon by so many other engineers who were simply too afraid of pissing off everyone else to take a few minutes to reformat the damn code so I, at 2:30 am, could make sense of it.

While I enjoy the friendship of my fellow workers, I have to remind everyone that when you work for a company, you’re not there to make friends and be sensitive to other co-worker’s feelings. If the company has a coding standard, and you’re not adhering to it 100%, you’ll get no sympathy from me when your code gets mercilessly reformatted to adhere to the coding standard. And don’t cry about it; Learn from it and be thankful that your senior software lead didn’t come down on you like a ton of bricks.

I know this makes me seem like a heartless draconian beast, but I promise you that you too will side with me the first time you are forced to pull a 36+ hour stint wading through horribly formatted code while hunting for that last crash bug.

Oh, and as for tabs vs spaces, I really couldn’t care less as long as the company/team has an established coding standard. (Say, 3-space tabs or whatever.)

Even if your editor inserts spaces when you press tab won’t you need to press backspace four times to unindent, or is it smart enough to see that?

I don’t know because I’ve always just used tabs, I’ve never seen a reason to do otherwise. After all, what else would you use the character for?

That said, only a moron would use tabs to format their code.

Thank you! Long live spaces! :wink:

How about this: if your code repository lives on a Unix-y system, every check-in is automatically run through the indent(1) utility with the appropriate options for the project’s coding style:

Most larger projects also have a style guide as well:

There should be sample configuration settings for a variety of editors that are being used by the team ((X)Emacs, vi(m), etc.).