Well, if we’re going to use tabs, what do we mean by tabs? Up to the tabstop or 4 space equivalent?
I’ve been around a liiiittle [shifty eyes] and it was the other way around - back then there was actually a good case for using tabs instead of spaces because a tab uses 1/4 the memory and disk size of 4 spaces (or a whopping 8 if you’re using 8 space tabs). With all the indentation of C and ASM this adds up, though not a problem with old style BASIC. Now it’s not a big deal.
If we’re going this way I’d say it was people who were still stuck back in the 1990s and early 2000s and hadn’t updated their world views yet. I used to make fun of python’s formatting, now I love it.
My first hypothesis would be a combination of generation, languages and platforms.
Well, if there’s some reliable way of distinguishing such files (e.g. name always ends .tsv
), a sufficiently advanced editor (cough vim cough) will be able to toggle the tabs-or-spaces setting automatically.
Is there any editor other than Notepad that doesn’t let you toggle the visibility of non-printing characters? Even Word will display spaces as dots and tabs as arrows if you ask it to. ETA: also, syntax highlighting. Make those suckers light up in neon pink.
The sensible category. set expandtab
FTW.
Reminds me of this gem posted a while back:
VS defaults to tabs, but it’s trivial to change to to use spaces instead.
I favor spaces, because the exact representation of tabs is deeply dependent on your viewer/editor.
My (totally unverified) assumption is that basically no one but a total n00b actually saves a source file with tabs in it.
Your assumption is wrong, like I mentioned before, if you have a team of different people with different preferences, keeping tabs means they can stick to their own indenting style without having to reformat the document every time they open a file, annoying everyone all the time. The exact representation of tabs being dependent on your viewer/editor is exactly why it’s a good idea, all decent editors are configurable in that regard.
jwz covered the ancient history here well:
Unless you’re Rob Pike, and then you design a whole language with tabs to help you code in proportional width font! (apocryphal)
I like using, and would prefer to use tabs, but I use spaces most everywhere because invariably a copy-paste operation happens that blows away the tab, and I can never remember the tabstop syntax in vi when I need it.
Reminds me of my other oft-used but seldom found feature - vertical select.
I’ve used whatever is customary at the places I’ve worked at (because in the old days, whitespace changes were included in version control diff’ing which meant aesthetically displeasing code reviews if you happened to switch between the two) and haven’t noticed any difference to the workflow or my salary.
Edit: the “old days” being a couple of years ago.
I use emulated tabs. The tab key inserts spaces up to a multiple of four spaces. What does that say about me? Well emulated tab people don’t earn enough either.
That’s the “uses spaces” category. Most space-users still use the tab key, they just use it to insert the standard number of spaces.
That just makes you a normal space-using coder.
I prefer 2 or 4 spaces, but the worst is editors that secretly change all existing tabs/spaces in any file opened, resulting in tons of mysterious files and lines changed showing up on next commit. Looking at you, Atom.
Vertical select is incredibly useful. There are people who aren’t constantly using it? Or do you just mean there’s lots of text editors that don’t support it?
Speaking as someone that’s Team Spaces, I have to say this:
Tabs are fine.
Spaces are fine.
Mixing the two in the same file indicates that you want to watch the world burn.
I prefer emulated spaces; the space bar inserts tabs set to one char width.
You are an evil, evil person.
As YA grey haired programmer, I’ll add that the most important point is to be consistent with the existing style of code files and not uneccesarily change white space.
Sure white space differences can be annoying, but folks meaninglessly destroying blame/history by “making it pretty” is the worst.
As far as new code, well that depends on the language/framework’s culture. I find most I use today (Javascript, Ruby, Scala) are hip with double-space indentation these days.