-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: hard_tab = true
by default for accessibility
#4067
Comments
There was extensive discussion on this topic in rust-lang/style-team#1 that resulted in the decision for |
Thank you so much for the pointers! |
Thank you very much for the pointers! From what I have read, @nrc started rust-lang/style-team#1 to determine a default indentation width in the first place, and due to the consistency preference @nrc already favored space. In the entire thread, "accessibility" is never mentioned; "visually impaired" is only mentioned once by @Alex-PK, carelessly dismissed by @ssokolow with "Can we get a genuine visually-impaired person to comment on this?", and forgotten since. With the reddit post, we have a second-hand account of visually impaired people's comment on tab vs space. People with different visual difficulties need very different tab widths. I believe it is time for us to invite more people from the visually impaired community into the discussion and reassess the influence of the current default on their participation. I share your doubt that it will be difficult to change this. But the accessibility community is no stranger to such challenges, from accessible public transit to accessible workplaces. I have confidence that the indentation challenge is not larger than those. In the meantime, I will participate in the support of tabs as @nrc called for. |
I never intended it to be casual dismissal. I honestly want input from someone who actually needs this, rather than second-hand input or even possibly just guesses by people with a personal preference for tabs. That aside, isn't the purpose of something like rustfmt to be powerful enough that a person with a visual impairment could plumb things together so that it could automatically reformat to hard tabs on checkout, then reformat to whatever the project calls for on checkin? Wouldn't that be a more optimal solution, given that many projects are likely to override any |
I am sorry I characterized your question a bit too harshly. But I know if I want feedback from people with any disabilities I almost always have to actively look for them in addition to asking. People with visual difficulties already have more trouble learning to program, accessing code and contributing to projects. Asking them to compose some plumbing on top of that only serves to dissuade more of them, and partly why we could not even find one of them for comments. The purpose of Something like LF↔CRLF conversion definitely helps during the transition, or if the more inclusive style is not agreed upon as the standard. |
Fair enough. In hindsight, I was also feeling irritable and let myself be more blunt than I should have been. At minimum, I should have phrased it more like this:
But that makes an assumption about how willing people will be to stick to the rustfmt defaults, which could leave everyone more inconvenienced and people with visual disabilities still having to cut together a solution to translate between project defaults and their needs. People switched away from tabs for good reason: Because the ecosystem had multiple decades to come up with a solution and it's still an unreliable mess to get rendering of tabs in agreement across all sorts of different things. Not to mention that most applications don't obey things like That's why you wound up with things like It'd be much better to just cook up and clearly document an official accessibility solution which works everywhere, comparable to how Firefox's "Language and Appearance" preferences have an "Allow pages to choose their own fonts, instead of your selections above" checkbox you can uncheck and an "Override the colours specified by the page with your selections above" dropdown which defaults to "Only with High Contrast themes" and can be switched to "Always".
Note this line from my original concern:
Using tabs produces real problems for the majority with normal vision and, if you try to force them without a proper solution, you run the risk of seeing either a ton of |
That's the common narrative, and I'd like to question it. Why is "get rendering of tabs in agreement across all sorts of different things" the goal in the first place? Personally I only want my indentations to be consistent. I just have not realized until now that consistency is unrelated to the width. I am fine with 8-space tabs. My theory is that a vocal minority who align variables beautifully, who regard their code as "art" and insist on seeing it the same everywhere, cared about their code deeply enough to have made the first wave of automatic code formatters to enforce their styles across their projects. They valued consistency first, so they chose space. Then projects pick up those tools appreciating the consistency, but not caring much about the indentation width. Unfortunately, they then leave the silent minority who need to customize indentation width behind.
Yes! I totally agree. But let's look at your example:
We can choose our tabstops. The checkbox exists, in the form of whether I enable EditorConfig or not. But it doesn't work. Using space is like using 𝔉𝔒𝔑𝔗 ("font" in Mathematical Fraktur Capital unicode). You cannot customize what is not specified in metadata.
The Golang community is a glaring counterexample to this assertion. In 2012 Fireside chat the Go team mentioned explicitly that they chose tab because tabstop can be personalized.
You are correct in the case of linters. But I agree that
I see you were in that thread too. So you know Therefore the relation table is:
I should caution that no causation can be derived from the table, but at least it shows no correlation between using tab as default and having alternatives. |
Evidence seems to suggest that you are in a small minority, as 4-spaces seems to be the "old standard" for anything still in major use that's newer than C or Bourne shell script, with languages that settled on standard styles later (either as younger languages or as languages new to automatic reformatting) typically opting to develop conventions built around 2-space indent steps instead.
Here is a sampling of all the code formatters I'm aware of, young and old, across a wide range of languages. I think the patterns which show up in it across such a wide range of languages, which were developed and/or came to automatic styling at widely varying times, should call your hypothesis into question:
...and I went through the popular ALE plugin for Vim to make sure I wasn't missing anything popular. Those are all the tools ALE supports which I was able to identify as caring about code style and which have an opinion on tabs vs. spaces, plus a few more it doesn't. (Some, like clang-format, appear to have no default style and require you to read through a configuration guide before you can use them.) The recurring theme is "indent with 2, 3, or 4 spaces". The exceptions which, by their rarity, seem to support my point, are gofmt, shfmt, and https://beautifier.io/ shfmt makes sense in context with the modern C beautifiers generally refusing to choose a default, given that Bourne shell and C are ancient enough to come from the era when tab-based indentation was king. As for beautifier.io, it appears to default to tabs merely because the browser's drop-down widget defaults to the first entry when no preference for a selected entry is specified and the entries are sorted by their values, the number of bytes per indent step, in ascending order.
My point is that you're always going to see projects either overriding the rustfmt defaults or refusing to use rustfmt if that's not possible. It makes more sense to make a solid, easy-to-use way for those with accessibility needs to use rustfmt as some kind of load/save or checkout/checkin filter. That is the equivalent to Firefox's accessibility settings when considered based on reliability.
One case isn't exactly a powerful argument... especially when the design goals of the language, and resulting decisions such as the lack of generics and the late arrival of proper package management, may be inducing a bias such that its community preferentially selects itself for people willing to adapt themselves to the language. (Never underestimate the lasting power of the seed users to shape the user base demographics going forward. Google found that out the hard way with Google+.)
Except that you're generalizing from the example of a language ecosystem built around a non-configurable formatter and aggressive code conformity. That's not likely to be representative of the rest of things. (It causes enough trouble when incoming C and C++ programmers don't understand how important memory-safety and avoiding undefined behaviour are to existing Rust community members. I strongly suspect there's some self-selection going on which is pre-emptively avoiding the friction which would produce a gofmt fork.)
I wouldn't expect it to be. The |
@louy2 - To clarify my comment.. IMHO rustfmt is highly unlikely to change the default to tabs because the decision on tabs vs. spaces default has been a closed matter for nearly 3 years. As summarized at the end of rust-lang/style-team#1 (comment):
If you'd like to attempt to change that decision, I'd suggest opening a new issue in https://github.com/rust-dev-tools/fmt-rfcs/ because it's a highly contentious topic and making such a change would have a widespread impact. |
@ssokolow That said, I feel like I am not fully understood, and we are talking past each other a bit. Let me try to clarify myself a bit more. I am not disputing that the majority of the code formatters are using space. In the very quote you quoted I said:
I totally agree with your finding, and thank you again for looking into it for me. Indeed, we have authors who outright name the formatter "Artistic", and most of the style guides and formatters choose space for a consistent look. The majority of the programming community has bought into these tools because they prefer consistency to mixed tab and space. To solve mixed space and tab, the formatters need to indent either consistently with space or consistently with tab. For the implementers of the formatters, if they care much about alignment as well as indentation, because alignment uses space inevitably, it is much easier to implement with only space. #1081 shows an example of how the I take this for granted: Everyone prefers consistency to mixed tab and space. From the observation: The implementers of formatters prefer space to tab. I'd like to note that the implementers are only a minority of the programming community. That's the whole point of distributing such a tool, after all. Not observed: The majority of the programming community prefers space to tab. I simply hypothesize that most people do not hold a strong preference over this matter for them to change the default setting. Which also answers your doubt:
I'd like to note that you are also "[making] an assumption about how willing people will be to stick to the rustfmt defaults." I assume most people follow the default from the anchor effect of behavioral economics, while you assume the opposite, from a similar principle ("Never underestimate the lasting power of the seed users to shape the user base demographics going forward."). I take it that you think the seed users of Rust like to configure the formatter to their liking. One way to resolve this difference is to scan the crates repository, pick only those which uses
I agree that such a tool would be very helpful. I can already imagine using
The EditorConfig tabstop setting cannot change space. Firefox's accessibility font setting cannot change 𝔉𝔒𝔑𝔗. They are as unreliable as each other. The tool aims to be reliable beyond that.
From the thread you were in:
If anything, gofmt is more configurable and less aggressive than rustfmt. It is more configurable not by having a configuration file and many options, but by preserving much of the style already present in the code. That we put up with rustfmt, heck, that we put up with the steep learning curve of Rust, is the actual story of "adapting ourselves to the language". Go, being simple and easy to pick up, is selecting for people who do not want to adapt much. |
Bear in mind that it's a formatter primarily for C and C++. When I did my little survey, I found it puzzling how clearly and significantly disjoint the design philosophy for C and C++ formatters was from all other formatters... even the much younger clang-format. (possibly because C and C++ seem to be the only pre-1990s languages of note with such longevity and market share and that's affected the culture that produces said formatters.)
Good catch. Even with spaces, the examples in #1081 embody the main type of rustfmt decision (which is independent of spaces or tabs) which prompts me to only use it infrequently... wasting vertical space on a non-portrait monitor. However, requiring hard tabs would make it impossible to go for the design I use unless it was smart enough to use tabs within a line to align arguments. Also, one thing I haven't seen you touch on is formatters rewrapping ines to fit line length limits. I don't know about others, but I find that I often trim down local variable names to preserve the wrapping points necessary to keep good scannability in long method chains or banks of test asserts or what have you. The readability of my code when the indent size or line length constraints have been altered is "WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED".
It'd certainly be an interesting thing to see if nothing else. How many people who root around to learn how to change their tabs from 8-spaces, and how many editors would be revealed to have poor/no support for setting it on a per-language basis?
I see two difficulties ensuring that meaningful conclusions can be drawn from that data. Specifically, you'll need to find ways to measure or estimate the portions of the population who...
Part of what I was trying to convey was that, because the implementers of formatters almost universally prefer spaces, any language which uses tabs in its formatting will represent a lack of consistency between languages. That also needs to be considered when judging how to approach things. In my experience, people prefer deviations between languages to be justified by associated advantages. Tabs vs. spaces is the utlimate bikesheddable disagreement.
Actually, the intent behind the statement you quoted was more in the vein of "A proper solution is going to need to deal with projects that defy the push for tabs anyway, so why push to inconvenience the majority of users before we've seen how far a universally applicable solution can take us?"
The problem is that the "wheelchair" I propose works equally well whether or not "the building has ramps and elevators", we're not in a position to legislate that every "building" has this, and, whether or not they had a specific problem with the outcome, it would inconvenience and annoy a great many people to arbitrarily change things which were working just fine for them before. (Not to mention potentially trash git diffs for anyone who wasn't warned to check in all their pending changes before upgrading rustfmt, then run rustfmt before making new changes.)
I don't see how those are comparable. The approach I propose would be built on top of rustfmt... something specifically designed to reformat the code with understanding of its structure sufficient to rework the whitespace as is needed. If anything, EditorConfig's tabstop setting is a better analogy for what you propose, because rustfmt defaults can be overridden and rustfmt is optional.
I'll certainly agree that rustfmt is a bulldozer that needs to be improved but, to some extent, it also depends on what you consider to be a hindrance and what you consider to be a help. For example, there's a Python lint that I'd normally want... ensure that all imports are at the top of the file... and then you run into things like PyGObject, where I haven't used gofmt, so I can't judge it, but I feel skeptical of its ability to be that much better than rustfmt at telling the difference between "style" and "stylistic typo". I think they just chose different balance points between the two concerns. (Plus, they're also, to some extent, expressions of the different cultures that produced them. The Rust compiler catches a lot more at compile time than the Go compiler.) |
Bit of a bump on an old-ish bug so hopefully people will forgive me but as someone who is affected by this for similar but different reasons than the case OP mentions let me throw in my real first-hand experience. One that I've literally just had today with Rust that lead to me finding this thread. It might be useful in the future for others to point at if they can jump on the language before the tab vs spaces decision is made. But I suspect I've missed that boat at this point for Rust. I'm dyslexic and as a result I can struggle with alignment of things when it comes to code. My standard is the 8 spaces size tab. 4 makes my life difficult in that I won't be able to skim the code anymore; I'll have to go slow and really read it. I'll need to take a really good look at each line, sometimes multiple times, to make sure I've properly picked up on the indentation level. 2 space indents literally are not there most of the time. Terminal related editors are actually pretty good with this, defaulting to 8 spaces (Nano, Vim). If I need to edit a file, lets say a config file, quickly in a terminal I can pull those up and if it's indented with tabs I'm good to go immediately. If it's not I'll end up doing sed "s/ /\t/" to make it tabs so I can properly read it, then roll it back later. But you'll note that depending on the context and syntax of the file that's not always safe. In my experience in programming languages it's virtually never safe in anything other than small projects. One case being log lines and other things in strings where it's important the spaces are spaces and the tabs are tabs so I stopped doing that long ago on code. That means I need an editor that doesn't just do "spaces to tabs" but that understands the syntax of the file and what's safe to expand and what isn't. Was that space in a multi-line string? is but one question you can't answer with a per-line regular expression. But the moral of the story is if I end up in that situation, I'm pretty much excluded from working on it in a timely manner without a full on syntax aware IDE setup and customized to back up my efforts. Mostly to cope with quick one-offs I've learned to use the Anyway, onto the Rust encounter. After posting mozilla-mobile/fenix#14582 I started digging into why it was broken to see if I can fix it. I believe I've tracked down the library with the issue, never used rust before so spin up a quick blank VM, install rust, download the library, I finished work at 5pm and tried to quickly knock a Firefox bug out I already think I tracked down by clicking around Github. One line change and a unit test. It's now 8pm and I'm still setting this up with rustfmt to make it easily editable and haven't stopped yet to go make dinner. If this was indented with tabs Vim would have picked up my tab setting and I'd be done by now and have a pull request sitting upstream assuming the change worked. I haven't even gotten to the point of finding out yet! I've seen this more than once in Rustfmt, Python, etc. refereed to as a "bike shed argument". My understanding of the term is that it's a "lengthy, unproductive discussion over a minor issue". I'd like to call out at this point for me and others this affects it's not a minor issue - it's the difference between people affected by this like me being able to read it reliably or not and we end up working around this before we can do anything productive. What should have been a quick introduction to the language and knocking out a bug in an open source project has turned into a multi-hour saga of learning the formatting tool and building that plumbing of the formatter around the editor that was referred to in earlier posts. I'm having to learn the formatter before even learning the compiler. I once had to waste more than half a day debugging Vim because someone upstream decided to include a "force space indent of width 4" into Vim for python files in such a way as it overrode my own settings in .vimrc and if I wanted them back I had to override their override in a specific file for that filetype. But I had to figure that out before I could read and write the code properly again. Perhaps it's a bit oversensitive - but IMO if this was any other accessibility issue like color blindness it'd be a hunt to find the right thing with a UI review required before release to ensure it was acceptable. Blindness? Look at aria appearing in HTML much more and frameworks like bootstrap including it in their examples. But in my time coding spaces are becoming more common not less, communities are adopting common style guidelines (good) pushing people to default to spaces (bad) and coding is becoming less accessible to me not more. There's a real accessibility issue here and the community across many languages is calling it a bikeshed issue and going the wrong way. If it's a tab Vim or any editor these days picks up everybody's favorite setting, mine, yours, theirs. If it's a space it is only yours - and I end up where I'm sitting now debating if fixing a bug in Firefox for nothing is really worth the hassle this is currently puting me though. P.S. It's been mentioned in the previous threads that the majority of the community is clearly on side or indifferent. I'm sure that's absolutely true. Most people are indifferent to wheelchair ramps too. Your criteria for accessibility can't be majority support. Accessibility often relies on people making these decisions to side against the majority and towards accessibility. Yes, people could always do the opposite and manually set it to spaces but the fact is the agreed guidelines and the defaults do carry weight and do make a difference.
|
Thank you. :) |
I appreciate the opinions and perspectives shared here, but I'm locking this conversation as resolved because ths issue (and this repo) is not the right place for the discussion. rustfmt's defaults are explicitly and strictly governed by the Rust Style Guide, and that Style Guide explicitly requires the default value for |
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).
The text was updated successfully, but these errors were encountered: