5 ms·
"So these are my pro-Tabs reasons. You might think some of them as BS but they are rational and you can’t disagree with that.". I disagree. "1. Tabs are meant
by coreyp_1 9y ago
"So these are my pro-Tabs reasons. You might think some of them as BS but they are rational and you can’t disagree with that.". I disagree.
"1. Tabs are meant for Indentation".
On typewriters, yes. For the beginning of a paragraph, yes. But for programming? No. Why would you mix a character of undefined length (a tab) with characters of defined length (all other printable characters, including the space character)?
"2. Tab-based indentation is uniform, like spaces"
No, it's not. It changes from editor to editor. Some editors make it easy to change the tab size representation, and some make it difficult. When reading someone else's code, you have to change your tab size to whatever their tab setting was if you want comments to line up correctly. The real headache comes when you are trying to use code from one or more outside sources, and they both used different tab sizes. It makes reading the code a chore.
I will say it plainly: Code (higher level languages) is for the ease of understanding of the programmer. Anything that gets in the way of that, including weird spacing, is wrong.
"3. Tabs work better with Notepad"
The last time I checked, the space bar works just fine in Notepad. "Oh," you may say, "I don't want to have to push the space bar that many times! It's hard!". Really?!? That's just being lazy. I prefer not to use auto-indenting because it makes me more aware of the flow of my code. In fact, most of the time it gets in the way, as it does not do the indentation that I want, and I don't care to spend the time to figure out what obscure setting that I need to tweak to fix it; I have more important things to do! For context, I've been programming for 20 years now.
"4. Code size with tabs indentation is lesser"
Why does that matter? Code is for programmers. Compiled versions are for computers. The compiled version does not change regardless of the form of whitespace used. For modern computers, quibbling over source code size (especially when it is only a few kilobytes) is like complaining because there is a sheet of paper taking up room in a shopping basket. It's negligible.
"5. Spaces Indentation takes more time to fix"
Most IDEs have tools that address this exact issue. I, however, don't use them, and it doesn't impact my output volume. These types of changes (refactoring, really) are few and far between, and therefore make it sound like you are grasping at straws.
"6. Spaces promote super-ugly & inefficient code style"
Beauty is in the eye of the beholder, and you yourself are advocating a style that I think is harder to read. I will choose the spaces version, thank you very much.
- flukus 9y ago> No. Why would you mix a character of undefined length (a tab) with characters of defined length (all other printable characters, including the space character)? To allow individuals to define the length of course. I like to free up horizontal space and a tab width of 2 spaces helps me do that, I can't with 4 spaces. This is especially apparent in c# were you're 12 spaces in before you actually get to the real code.
- coreyp_1 9y agoI use 2 spaces. The argument stands, though. Code is meant to be read by programmers. If the code you write is unreadable (because of too many spaces), then it is wrong, too. Full stop. I work with a lot of beginners. That is, I teach University programming classes (C/C++), and have for several years. Tabs confuse beginners to no end, because they are different everywhere. Their code looks different from their lab partner's. Their code looks different from the person sitting next to them. They think that they're doing something wrong. Then, when they try to look at someone else's code, it doesn't look right, either, because they don't know how to adjust the tab width setting in whatever editor they are using (it could be Sublime, Notepad++, Vim, Nano, Emacs, etc.). It's just another hurdle for them to think through, and more time lost in a lecture trying to explain it. I have learned my lesson. As a teacher, I teach them to use spaces. When I was an industry developer, I used spaces, too. When I have to read code that forces a 3 space tab in order for everything to align and to be read clearly, or any other size (which means that I have to adjust my editor's settings just to read that 1 file), then the programmer, IMO, is doing it wrong. You may prefer tabs, and I abhor them. We can agree on that. I took issue with the tone of the blog post, however, which completely ignores issues that to me are painfully obvious, and then claims that his opinion is rational (implying that an opposing view is not). I very much disagree with his interpretation of the issue, as well as his conclusion.
- flukus 9y ago> When I have to read code that forces a 3 space tab in order for everything to align and to be read clearly, or any other size (which means that I have to adjust my editor's settings just to read that 1 file), then the programmer, IMO, is doing it wrong. You see what you've done though? You've defined everything that is not your personal preference of 2 spaces (I could live with this one at least) to be wrong. > Code is meant to be read by programmers. If the code you write is unreadable (because of too many spaces), then it is wrong, too. Full stop. Oh please tell me this universal definition of readability you've come up with, because the industry standard is 4 spaces that you apparently find unreadable. What you find readable I do not and that's what tabs are for, we both get the readability we desire. > Tabs confuse beginners to no end, because they are different everywhere. Their code looks different from their lab partner's. Their code looks different from the person sitting next to them. They think that they're doing something wrong. Having a class standard makes perfect sense, just like having a company standard does. But they're going to run into much bigger issues than tab sizes. There will be different fonts, different font sizes, different line wrapping, different colors and different screen sizes. All of those will produce different looking code, but I don't see anyone standardizing on those things.