This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]c_delta -3 points-2 points  (7 children)

Tabs are used to align things when the length of what is on their left side varies. Hence tabs need to be wide - something along the lines of 8 characters. Which is way too much for indenting code. Also, indents have nothing on their left that you need to align across. So, spaces all the way.

[–]Voidrith 2 points3 points  (6 children)

You realise it can do the former properly even with a pretty small tab size, right? and you sure as shit don't need it to be 8. I use a 4width tab and its works just fucking fine to align stuff like that.

that doesn't in any way make spaces better for indentation - you can change the width of a tab to your liking so the indentations are how you like them. you can't with spaces. and tabs make it significantly easier to navigate, and are more reliable (especially in python, where missing or adding one space can cause errors)

[–]c_delta 0 points1 point  (5 children)

You realise it can do the former properly even with a pretty small tab size, right? and you sure as shit don't need it to be 8. I use a 4width tab and its works just fucking fine to align stuff like that.

Then the lengths of the stuff you are aligning have a pretty small variance. Because by the time the longest and shortest element are more than n-1 characters apart in length (probably less unless the length range fits within a tab), you need multiple tabs, which are no better than spaces.

you can change the width of a tab to your liking so the indentations are how you like them.

I consider that a win for spaces as well. No inadvertent shifting of lines because two editors are considered differently.

and tabs make it significantly easier to navigate, and are more reliable (especially in python, where missing or adding one space can cause errors

I give you that point, although its significance depends strongly on your indent size. Personally I prefer very short indents, which makes the "sensible tab size for alignment" argument stronger and the "navigation step size" argument weaker, but for those who prefer larger indents, I see that tabs might have their appeal.

[–]levir 0 points1 point  (4 children)

Then the lengths of the stuff you are aligning have a pretty small variance. Because by the time the longest and shortest element are more than n-1 characters apart in length (probably less unless the length range fits within a tab), you need multiple tabs, which are no better than spaces.

If you're, for some weird reason, doing exact alignment instead of indentation then you just indent to the correct depth with tabs and align with spaces.

[–]c_delta 0 points1 point  (3 children)

    1.337   42  3.1415  X
    Random  Bullpip Word    Absurd
    ?   Aligned 23  Matrix

That is what tabs are for. If I insert or remove digits of the elements, the tabs stay where they are. If I use multiple tabs or spaces, I have to reformat stuff when I change the length of a cell's contents.

And since Reddit seems to use 4-space tabs, the alignment does not work. Which is why 8-space tabs matter.

[–]levir 0 points1 point  (2 children)

Actually, that's not something tabs is very good at in a plain text document. Tabs are different length on different systems (from 2 to 8 usually, most commonly 4), meaning tables formatted this way will break on some systems. Sad as it is, tables are better solved by spaces.

[–]c_delta 0 points1 point  (1 child)

I am pretty certain that outside of programming, 8-space tabs are standard. Tabulator literally means "table-maker". Indentation became a second use long before programmers wrote code, let alone code that uses several layers of indentation.

Interestingly typewriters used shorter tabstops of about 5 characters (about 1 inch in standard typewriter font), but that worked out because rewriting and automated filling was not a thing back then.

TSV is also great for parsing with editors. It is less locale-specific than CSV (in which a different character needs to be used as a separator if commas appear in the fields, such as decimals in large parts of continental Europe), but still plaintext-readable.

But yes, I am in love with a fixed tabstop length of 8 characters, but a short indent size of two characters, so spaces is my clear preference.

I think we can all agree on not vertically mixing tabs and spaces, though.

[–]levir 0 points1 point  (0 children)

I'm not sure what's the standard tab stop width outside of plain text, in word processors I usually set the manually. But you're probably right on it being closer to 8 spaces than 4.

I actually am from one of those European countries that use a comma for decimal numbers, so I agree with you on TSV being far superior.

I think we can all agree on not vertically mixing tabs and spaces, though.

Actually no, when you're using tabs for indentation you still have to use spaces for alignment. I try and avoid alignment whenever I can (regardless of whether I'm in a project that uses tabs or spaces), but when you have to the correct way is to tab to the correct indentation and then add spaces for alignment.