It's because at some point, your code <i>will</i> encounter low-tech technology that doesn't let you set the tabstop. This might be a terminal app, or an actual dumb terminal, or a cut & paste into a textbox on a webpage, or a third-party tool that expects spaces only, or a refactoring tool that you wrote yourself but don't have time to get working with tabs, or a parser that can count characters but has no logic for tabs. When this happens, your tab-based formatting will get messed up, while your spaces-based formatting will look exactly the way you wrote it.<p>A lot of mysteries about why people don't use clearly-superior technological solutions are solved by understanding that ubiquity is a feature, in many cases the most important feature. I don't use vim because it's the best text editor; I use it because I can be reasonably sure every single UNIX-like system I ever log into will have it, and once it's in my fingers from having to learn it on a remote server, I might as well use it for daily programming. I don't use HTTP because it's an efficient protocol; I use it because every single device, library, and language speaks it. I didn't write Gumbo [1] in C because I like the language; I did it because every modern language can bind to C libraries, and so this lets a maximum number of people use it.<p>[1] <a href="https://github.com/google/gumbo-parser" rel="nofollow">https://github.com/google/gumbo-parser</a>
Oh god. You might as well have posted, "Why do people use Mac instead of Windows?" in the year 2002.<p>People use spaces <i>because</i> they're a fixed width, not in spite of that fact. They allow you to know that your code will look exactly the same with any monospace font, which is especially important if you do things like lining up operators.<p>I personally use a hybrid: the entire line is indented with tabs. This tells you which block you're in.<p>Then, for alignment or anything else that isn't related to the entire block, I use spaces.<p>Many IDEs support this hybrid mode, including the IntelliJ family. It gives you the best of both worlds.
> tabs actually use less space on disk as only one character is stored instead of 2, 4 or 8.<p>If I didn't have the ability to store 1,000,000,000,000 of them, I'd care greatly. To be honest source code size isn't even in the ballpark of concerns I have. Intermediate bin files (e.g. obj files) are far larger and problematic for source control and sending source to someone (e.g. several meg a piece rather than a couple of hundred KB).<p>As for an answer to your question: Spaces are an exact width. Tabs change widths. Therefore for precision and reproducibility spaces are a better choice across all platforms.<p>Many IDEs support inserting a preset number of spaces when you tab anyway, so the problem is invisible to you.
Because sometimes you <i>must</i> use spaces, because you are indenting a continuation line that should be indented to an exact spot with respect to the previous line (you're in the middle of an expression, you want to be at the start of an open parenthesis, etc).<p>Surely the suggestion in that case is not to carefully insert tab characters to the same indentation of the previous line, and then spaces for the rest, so that you have some tabs and some spaces on the continued line? Anything else fails if the tabs are set as "developer preference" on display, but that tabs + spaces on one line is incredibly fiddly.
Even though I prefer to use tab characters at home it would be much better if a single tab character could indent the code to the appropriate level. So a tab character means indent the code to where appropriate based on some predefined rules. Granted this is only possible for some languages and not others, and it would be much nicer even when using a non-flat file for code.
The guy that had to use punched cards to enter code that would be printed to paper.<p><a href="http://computers.mcbx.netne.net/media/pcards/k_cobol_cyf.jpg" rel="nofollow">http://computers.mcbx.netne.net/media/pcards/k_cobol_cyf.jpg</a>