Hacker News new | ask | show | jobs
by gaazoh 977 days ago
Not everything Google does is gospel, it feels kind of weird that you post these without further context.

Although most coding guidelines seem to have converged towards spaces over tabs (see [1], [2],[3], your source, and many more), it also causes accessibility issues, especially for visually impaired people.

Some people require larger fonts, making space-indented lines go offscreen quicker. Some people require braille displays, which have a limited line length. A tab takes a single character on these, vs multiple (usually 4) for space-indented code. Some people require bigger indents to be able to process them better.

Not even considering disabilities, some people prefer 2 spaces, some 4, and some whatever pleases them. Working with tabs allows everyone to work on the same codebase with their own preference. By definition this is a subjective matter, and trying to enforce a preference across a whole codebase or programming language is needlessly opinionated.

Plus, the 2 first example use case in the article can't be solved either with spaces or standard tab stops.

---

[1] https://peps.python.org/pep-0008/#tabs-or-spaces

> Spaces are the preferred indentation method

[2] https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals...

> Use four spaces for indentation. Don't use tabs

[3] https://www.oracle.com/technetwork/java/codeconventions-1500...

> Four spaces should be used as the unit of indentation. The exact construction of the indentation > (spaces vs. tabs) is unspecified. Tabs must be set exactly every 8 spaces (not 4).

While leaving tabs vs. spaces "unspecified", specifying stabstops of 8 spaces actively discourages tabs

1 comments

Thanks for all the additional info! I should have added that my preference is for the definition of a unified gospel throughout the codebase/organization, Google's just being the one we ended up picking.

>Working with tabs allows everyone to work on the same codebase with their own preference.

This is where the problem starts. As someone who has to integrate code from a dozen devs, it seems that everyone has a sligthly different usage of tabs (TFA adding one more). If we can ever set everyone on the same page with tabs, I am fine with it. It's just that in production it always seems to cause problems. Spaces are easier to specify.

For the case of disability support, I'd risk to guess that different usages of tabs would end up derailing accessibility software just as much as it derails integration. But I'd prefer deferring this opinion to someone who has experience with it.