4 ms·
I see tab widths being configurable in editors as a major advantage over spaces. No more arguing over how many spaces, just use 1 tab and configure your own tab
by hboon 14y ago
I see tab widths being configurable in editors as a major advantage over spaces. No more arguing over how many spaces, just use 1 tab and configure your own tab width, including for Python.
In your experience, can you give an example of recurring bugs related to not being able to distinguish between tabs and spaces?
- lutusp 14y ago> In your experience, can you give an example of recurring bugs related to not being able to distinguish between tabs and spaces? Sure -- in Python, a mixture of tabs and spaces. This is certain to result in indentation that looks right to the human, but produces perverse results when interpreted by the language. > I see tab widths being configurable in editors as a major advantage over spaces. The sole advantage of tabs is that they can be globally replaced by spaces, after which the program can be analyzed and repaired to undo the damage the tabs produced. Also, did you think about the above remark? If you change the meaning of tabs in the editor, there's no easy way to let the language know what you decided. The outcome is that the editor operates under one assumption, and the language operates under another.
- burntsushi 14y ago> Sure -- in Python, a mixture of tabs and spaces. This is certain to result in indentation that looks right to the human, but produces perverse results when interpreted by the language. Python (and Haskell) are pathological cases because the syntax of the language depends on whitespace. There are very good reasons to avoid tabs in those languages. I don't think you'll find many people that disagree with you on that one. But your argument is that tabs should be abolished, regardless of the language. So I'd ask: In your experience, can you give an example (in a language that does not care about whitespace) of recurring bugs related to not being able to distinguish between tabs and spaces?
- lutusp 14y ago> In your experience, can you give an example (in a language that does not care about whitespace) of recurring bugs related to not being able to distinguish between tabs and spaces? Translation: "If we eliminate any chance that a tab will be misinterpreted, can you think of a case where a tab might be misinterpreted?" The issue are those cases where tabs do lead to confusion, not where they don't.
- burntsushi 14y ago> Translation: "If we eliminate any chance that a tab will be misinterpreted, can you think of a case where a tab might be misinterpreted?" This is inconsistent with your initial statement: > After nearly 40 years' experience in programming, I offer that (as to computer source code) tabs should be outlawed. You said nothing about "programming languages that make whitespace significant." Therefore, I was asking why you want tabs outlawed in other languages. If this isn't the case, then we're in agreement---but your initial post was misleading.
- hboon 14y ago> Also, did you think about the above remark? If you change the meaning of tabs in the editor, there's no easy way to let the language know what you decided. The outcome is that the editor operates under one assumption, and the language operates under another. If I use tabs, then Python will just consider a line that starts with 2 tabs to be indented one more level than the previous line with 1 tab, and so on. What I set my editor to display the tab as shouldn't affect how the interpreter reads it (unless I mix spaces and tabs, which while I don't think it's likely or common, I do agree you have a point there). Or did I misunderstand you?
- jabbernotty 14y agoThe problem is that different people use different editors that have different settings. One person uses four spaces, another used 8 spaces, and a third uses tabs. Suddenly, your python code doesn't work well anymore, commits/diffs become very confusing and web services that have source viewers produce messy views.
- lutusp 14y ago> If I use tabs, then Python will just consider a line that starts with 2 tabs to be indented one more level than the previous line with 1 tab, and so on. Yes, but that's at odds with how the code looks to a human when both tabs and spaces are used. Remember that I qualified my remark by saying it was about a mixture of tabs and spaces.
- mseepgood 14y ago> Sure -- in Python, a mixture of tabs and spaces. This is certain to result in indentation that looks right to the human, but produces perverse results when interpreted by the language. The question begins with "If it didn't matter syntactically with the programming language".
- lutusp 14y ago> The question begins with "If it didn't matter syntactically with the programming language". Not in the post to which I replied, that was added later -- review the thread.
- wglb 14y agoMakefiles.