I have decided to use only tab for all my indentation going forward. I used to use only space, but my mild inconvenience is nothing compared to helping people with visual difficulties participate in the communities.
Let me quote the linked reddit post, which I fully agree with:
aren't we all making our codebases worse as a workaround for the deficiencies in these websites we enjoy? why are these code-viewing apps missing basic code-viewing features?
in the tabs-vs-spaces debate, i see people saying "tabs lets us customize our tab-width", as though we do this "for fun" — but this is about meeting the real needs of real people who have real impairments — how is this not seen as a simple cut-and-dry accessibility issue?
About that "how": because people with disabilities are a minority, so they do not enter our thought processes when we focus on a "minimal viable product". Accessibility is most of the time an afterthought. But late is better than never. Let's think about how to make using tab indentation more convenient.
Unfortunately most style guides recommend space indentations. Most code formatters turn tab indentations into spaces by default. Where I can configure them, I will configure them to use tabs.
JavaScript (Prettier)
{
useTabs: true
}
JavaScript (eslint)
{
"indent": ["error", "tab"]
}
Rust (rustfmt)
// rustfmt.toml
hard_tabs = true
Haskell (Emacs)
Go (gofmt)
It uses tab by default!
If you do not see the language or the formatter you are using above, contribution is always welcome!
Discussions on making this default in each language:
Rust (rustfmt)
Discussion: `hard_tab = true` by default for accessibility #4067
Accessibility means accepting that code should look differently according to different needs.
I have changed my stance completely on tab vs space after reading this reddit post describing accessibility problems with space indentation. I believe it is worthwhile to change the default to using hard_tab = true
for the accessibility benefit. As a reference, go fmt
by default uses tab to indent as well.
I know this is not without dispute, and even if we all agree on this, we need a plan and it will be a time and labor consuming transition. So I want to start a discussion and see what we all think about this. What problems do you have with either option? What problems do you have now? What problems do you think you would have during the transition?
I believe the accessibility benefit would outweigh the cost. Parsing Rust is whitespace agnostic, unlike Haskell or Python, so I do not think it would break code, which helps. On the other hand, it may make some bugs more prominent, e.g. #3148 is a bug with hard_tabs
we have not fixed.
Using terms @nrc developed in #1081, this is only related to block indent, not visual indent (alignment).
I use spaces because I stick to conventions, but I would prefer tabs because:
I read a post about a guy with a severe sight issue, who, to be able to code, had a very large font size configured in his IDE.
But at this font size, four spaces are huge, and he had to scroll horizontally all the time.
So each time he edited a file, he changed spaces to tabs (which were displayed with a width of one space), and changed back tabs to spaces before to commit !
For most of us, the battle of tabs vs spaces is totally vain.
For some of us, it can change their everyday experience.