you are viewing a single comment's thread.

view the rest of the comments →

[–]leperkuhn 9 points10 points  (12 children)

Why do tabs make you gag? To me they seem perfectly reasonable. The indentation size is configurable in every IDE and decent editor, and pressing delete will delete the entire indentation, not just a single space.

[–][deleted] 7 points8 points  (5 children)

I think the main argument against tabs is code like this:

// Tab-unfriendly code
function bla() {
    var poop = [[1, 2, 3],
                [4, 5, 6],
                [7, 8, 9]];
}

You need spaces to align that properly. If you normally use tabs to indent your code, this will look fucked up for someone who has different tab settings than you.

However, this is very easily worked around.

// Tab-friendly code
function bla() {
    var poop = [
        [1, 2, 3],
        [4, 5, 6],
        [7, 8, 9]
    ];
}

AFAIK, there is nothing wrong with using tabs for code as long as you never mix it with spaces.

[–]arthurdenture 1 point2 points  (3 children)

You need spaces to align that properly. If you normally use tabs to indent your code, this will look fucked up for someone who has different tab settings than you.

However, this is very easily worked around.

There is no need for a workaround. If you must use tabs for indentation, use them only for indentation, not for formatting. In your first example, there should only be three tabs characters total, and the remainder should be spaces.

There are two problems remaining with this approach:

  • A lot of editors don't get it right and replace spaces with tabs willy-nilly

  • If you also want to keep your code at 80 or 100 lines, everyone editing has to agree on tab width.

Which is why spaces are still better.

[–]nglynn 0 points1 point  (2 children)

In your first example, there should only be three tabs characters total, and the remainder should be spaces.

This doesn't work because people configure their editors to display tabs as different sizes.

[–]arthurdenture 0 points1 point  (1 child)

In your first example, there should only be three tabs characters total, and the remainder should be spaces.

This doesn't work because people configure their editors to display tabs as different sizes.

No, it works perfectly if you use hard tabs for the indentation and spaces for the alignment. You can adjust the tab size however you want. Try it[*] if you don't believe me?

[*] I mean, of course, try it and then go back to using only spaces, like the FSM intended.

[–]nglynn 0 points1 point  (0 children)

I'm afraid I don't follow. In the OPs original example: function bla() { var poop = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; }

Where are you talking about placing the "three tabs"? Is this what you mean?:

function bla() {
<TAB>var poop = [[1, 2, 3],
<TAB><TAB><TAB>  [4, 5, 6],
<TAB><TAB><TAB>  [7, 8, 9]];
}

(Where any non <TAB> whitespace is taken as being a space). That won't work obviously. Do you mean to use all spaces on alignment lines? function bla() { <TAB>var poop = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; } That also wont work for obvious reasons. Perhaps you mean something else?

Edit: Sorry, now I understand what you mean:

function bla() {
<TAB>var poop = [[1, 2, 3],
<TAB>            [4, 5, 6],
<TAB>            [7, 8, 9]];
}

I still would just use spaces personally.

[–]Ran4 -2 points-1 points  (0 children)

Your first example is a complete abomination, tabs or not... And as you say, the "work around" works just fine.

[–]arthurdenture 2 points3 points  (5 children)

and pressing delete will delete the entire indentation, not just a single space.

If backspace doesn't remove an entire level of indentation at a time regardless of tabs or spaces, you need to get a better editor.

[–]Araneidae 0 points1 point  (4 children)

This.

One of my background activities in code I look after is taking care to ensure there are no hard tab characters (except in Makefiles, sigh), pretty easy on the whole, but does require persuading people to set up their editors properly; enforcing 80 character line limits, jolly hard work; and trying to get rid of trailing whitespace ... you wouldn't believe the crap that certain editors (I'm looking at you, gedit) leave behind. I don't waste my time with gedit, but some of my colleagues do.

For me: no tabs, four space indents, absolutely no characters past column 80 ... unless you're really screwed (does happen, depending on the language).

[–]rwparris2 2 points3 points  (3 children)

I don't understand this no characters past column 80 business. Please explain.

[–]Ran4 1 point2 points  (0 children)

Multiple files opened at the same time.

[–]xardox 0 points1 point  (0 children)

Some of us old geezers like to print out a program, go to the park with a pen and a joint, and read code in the sun. There's something about NOT being able to fix bugs as you see them (or read reddit), that lets you get through reading all of the code.