"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.
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.
> 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.
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.
> 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.
"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."
No, I've stated that making me change my tab settings to read your code is wrong. If you want to use 3 spaces, then that's perfectly fine with me. Just don't make me change my settings in order to understand what you have written.
"Oh please tell me this universal definition of readability..."
My universal definition is that code should be understandable. Not obfuscated. Not verbose. Whitespace is the issue that we are talking about here (but it is definitely not the only issue), and 4 spaces is fine if the code allows it. But if you have 11 levels of indentation, then 4 spaces is silly. Some languages lend themselves to a heavily-indented structure (especially object-oriented class definitions), and 4 spaces make them unreadable.
As for the last point, I agree, but I disagree that the variations in fonts and colors are of the same impact as having the wrong tab width. Again, I refer to my teaching experience. Colors, fonts, font sizes, line wrapping, screen sizes, etc., do not confuse beginners. Tabs do. They are invisible (unless you know the magic setting to make them visible in your particular editor) and they hide spaces (a space followed by a tab aligns with a single tab), which causes problems in a language like Python.
[edit: adding this paragraph]
The best parallel to the preceding argument is if you wrote code that required a specific font, color, etc., in order to read it clearly, then that would be bad programming, IMO. This is not the case, however, with any IDE that I have seen. That is also why I do not consider these variations to be of the same level as tabs vs. spaces.
I get it. Spaces are explicit; tabs are variable. You consider it a feature. I consider it a liability.
> No, I've stated that making me change my tab settings to read your code is wrong. If you want to use 3 spaces, then that's perfectly fine with me. Just don't make me change my settings in order to understand what you have written.
That's exactly what tabs do and exactly what spaces don't do.
If the code is tabbed then it will use the editors tab width and no one has to change settings. I can open the code on my computer and get a tab width of 4, you can open it on yours and get a tab width of 2, it'll show whatever tab width your editor is set to. Everyone is happy.
With spaces on the other hand, if I decide I want 4 spaces for indentation then you're going to get 4 spaces when you read the file. You'd have to reformat the whole file to be able to read it.
> I get it. Spaces are explicit; tabs are variable. You consider it a feature. I consider it a liability.
But you seem to want the variability, you don't want to be subjected to my setting of 4 spaces because you find it unreadable.
"But you seem to want the variability, you don't want to be subjected to my setting of 4 spaces because you find it unreadable."
No. I want consistency. If you use 4 spaces and it is readable, then I don't care. But I want to see it the way that you wrote it in order to make that judgement. If I am looking at two different files that were written by 2 different people using 2 different tab width settings, I don't want change my tabwidth per file, just to read it clearly. This is especially a problem where continuation indents are used, and all readability is lost with the wrong tab setting. It is needlessly messy. Using spaces (even if they each used a different number of space indent) would ensure that I see the file as they intended it to be read. That is consistency, and that is what matters to me.
If you use a different number of spaces than me, then that is entirely fine. By using spaces, then I will see your code as you see it. If you use tabs, then all bets are off.
I was learning make. I couldn't get the example in the Make book to work. Then someone explained that the line after a make heading HAD to begin with a tab. Nowhere was this explained in the book. Please, let us stamp out the tab which is a holdover from the IBM selectric era.
That's a good argument, but it's an argument against significant white space. Without knowing white space is significant you could have made the same error with spaces.
9 comments
[ 1.6 ms ] story [ 36.5 ms ] thread"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.
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.
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.
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.
No, I've stated that making me change my tab settings to read your code is wrong. If you want to use 3 spaces, then that's perfectly fine with me. Just don't make me change my settings in order to understand what you have written.
"Oh please tell me this universal definition of readability..."
My universal definition is that code should be understandable. Not obfuscated. Not verbose. Whitespace is the issue that we are talking about here (but it is definitely not the only issue), and 4 spaces is fine if the code allows it. But if you have 11 levels of indentation, then 4 spaces is silly. Some languages lend themselves to a heavily-indented structure (especially object-oriented class definitions), and 4 spaces make them unreadable.
As for the last point, I agree, but I disagree that the variations in fonts and colors are of the same impact as having the wrong tab width. Again, I refer to my teaching experience. Colors, fonts, font sizes, line wrapping, screen sizes, etc., do not confuse beginners. Tabs do. They are invisible (unless you know the magic setting to make them visible in your particular editor) and they hide spaces (a space followed by a tab aligns with a single tab), which causes problems in a language like Python.
[edit: adding this paragraph] The best parallel to the preceding argument is if you wrote code that required a specific font, color, etc., in order to read it clearly, then that would be bad programming, IMO. This is not the case, however, with any IDE that I have seen. That is also why I do not consider these variations to be of the same level as tabs vs. spaces.
I get it. Spaces are explicit; tabs are variable. You consider it a feature. I consider it a liability.
That's exactly what tabs do and exactly what spaces don't do.
If the code is tabbed then it will use the editors tab width and no one has to change settings. I can open the code on my computer and get a tab width of 4, you can open it on yours and get a tab width of 2, it'll show whatever tab width your editor is set to. Everyone is happy.
With spaces on the other hand, if I decide I want 4 spaces for indentation then you're going to get 4 spaces when you read the file. You'd have to reformat the whole file to be able to read it.
> I get it. Spaces are explicit; tabs are variable. You consider it a feature. I consider it a liability.
But you seem to want the variability, you don't want to be subjected to my setting of 4 spaces because you find it unreadable.
No. I want consistency. If you use 4 spaces and it is readable, then I don't care. But I want to see it the way that you wrote it in order to make that judgement. If I am looking at two different files that were written by 2 different people using 2 different tab width settings, I don't want change my tabwidth per file, just to read it clearly. This is especially a problem where continuation indents are used, and all readability is lost with the wrong tab setting. It is needlessly messy. Using spaces (even if they each used a different number of space indent) would ensure that I see the file as they intended it to be read. That is consistency, and that is what matters to me.
If you use a different number of spaces than me, then that is entirely fine. By using spaces, then I will see your code as you see it. If you use tabs, then all bets are off.