top | item 33442913

(no title)

robbick | 3 years ago

I can see this is probably a calm point that will definitely not escalate, programmers don't really care about tabs and spaces that much, right???

discuss

order

Accacin|3 years ago

Heh, I always wondered what the big deal was. I'll just use whatever the company I'm working for uses and not even think about it.

To be honest, that's why I love auto formatting cause I never need to think about that stuff, I can just write code.

spartanatreyu|3 years ago

"Tabs vs spaces" is often misunderstood (and falsely reported) as a problem of preference.

The real problem is that using spaces for indentation is an accessibility issue.

The solution is to use tabs for indentation, and spaces for alignment.

brianzelip|3 years ago

> The solution is to use tabs for indentation, and spaces for alignment.

It's the second step that drives me nuts. Why can't/doesn't alignment happen at first step? The inconsistencies of alignment using true tabs, in a monospace plain text environment, grosses me out and decrements my faith in the underlying systems. I appreciate editors w/ settings like `insert spaces when pressing tab` and `the number of spaces a tab is equal to`.

Aeolun|3 years ago

Why would you ever mix them?! Even when I started programming 15 years ago it was already accepted wisdom that that was a terrible idea.

kazinator|3 years ago

> The real problem is that using spaces for indentation is an accessibility issue.

The problem of leading spaces not changing their size can be solved through programming.

Those programmers who have such a problem and need leading space to be rubbery, if those programmers are worthy, will solve that problem instead of complaining that everyone should adapt to them.

The use of tabs is detrimental to code bases. Whenever tabs creep in, invariably people use different tab settings and make a dog's breakfast out of the code.

Code exhibits indented sub-structures that are internally indented, but not themselves not aligned to a tab stop, but aligned with something. One kind of example is something like:

  function_name_of_random_length(lambda (a, b) {
                                     if (a < b) {
                                         indented();
                                     }
                                 },
                                 arg2);

mathstuf|3 years ago

While that may be true, "spaces for alignment" is nigh unsupported by all editors I've seen. They insist on replacing 8 (or N) spaces with tab even if in an alignment region.

int foobar(int a,

___________int b) // should only ever have spaces (using _ here because HTML)

But good luck finding an editor that won't insert a tab when you use the tab key here (willing to be wrong).

The other issue I have is that diffs break alignment between undented code and anything with tabs because the tabs "eat" the leading space, but unindented lines are offset by one.

LanternLight83|3 years ago

I used to tout "tabs for indentation, spaces for alignment" until I started working primarily woth lisps. Idiomatic lisp indention isn't compatible with regular tab-stops, so the only solution is to go with spaces (maybe losing accessability) or, preferably, to go elastic.

https://nickgravgaard.com/elastic-tabstops/

eyegor|3 years ago

In soviet python, runtime cares

(if you accidentally use a tab in a file that otherwise uses spaces, you get a runtime exception, or vise versa)

bnt|3 years ago

Tabs