by amin on 5/17/21, 7:55 AM with 259 comments
by srl on 5/17/21, 8:18 AM
So there must be a confounder. What could it be?
- Do the top schools all instruct students to always use spaces? This should have been partly taken care of when the author controlled for level of education though, right?
- Choice of editor? This seems like a weird one, but editor defaults are definitely linked to tabs vs spaces, and the survey didn't even collect data on this.
- Starting language?
- Total number of languages used? Spaces are tolerable in more languages than tabs are. Of course, I'd expect "both" to beat "spaces" if this was the case.
None of these strikes me as particularly plausible, except maybe the last one. This result is kind of bothersome, because it's big, obviously not a statistical fluke, and hard to understand.
EDIT: a past thread (https://news.ycombinator.com/item?id=20719010) suggested that some higher paying companies mandate spaces. This also seems plausible.
by kstenerud on 5/17/21, 8:42 AM
- Tabs move the cursor to the next "tab position" but are invisible, which means that whenever someone hits tab in the middle of something (accidentally or otherwise for alignment), you end up with messed up looking text and alignment as soon as you view it with a different tab size.
- Trying to enforce "tabs only for indentation" rarely works without headaches because humans.
- Using monospaced characters everywhere means that you'll never encounter positional issues ever.
I've worked in 2-space, 3-space, 4-space, and 8-space indentation houses and honestly, I don't see the point of viewing indentation in your preferred size. It's easy to adapt to the house rules, and the benefits outweigh the headaches.
by mg on 5/17/21, 8:32 AM
Unfortunately in practice, two factors are in the way:
1) Most developers are confused by this type of whitespace usage. Simply because it is the less popular practice. So when you have a codebase that uses tabs for indention, you get more broken commits from developers who stumble in keeping the system intact.
2) Out of the box, VIM has no easy way to colorize tabs. So when you look at your code, tabs and spaces look the same. You cannot say from just if the whitespace is ok or messed up. You can show all non printing chars with "show list" but that is not very nice on the eyes. Or you can configure "show list" to only highlight tabs but then you lose the ability to show all non printing chars.
by strogonoff on 5/17/21, 8:49 AM
Furthermore, I believe that with certain indentation styles (e.g., when arguments in a function call align with the opening paren) tabs require that one extra preliminary step of configuring one’s editor in order to view the code properly, while with spaces that extra step has more optionality and is only needed in order to edit the code with auto-indent.
IMO since one has to adapt their coding style to the dominant style of the codebase (single/double quotes, etc.) either way, one might as well adapt to the indentation as well, so I’m not against spaces.
And of course, due to people who don’t take care to set up their tooling and end up mixing tabs and spaces for indentation, a particularly hot mess can arise—and what’s worse, that mess can accidentally look fine in editors that happen to be configured in a particular way. Because of that, I keep whitespace visibility turned on across my editors.
by xdrosenheim on 5/17/21, 8:07 AM
by elihu on 5/17/21, 8:15 AM
Or in other words: I know who's pulling down the average because it's me.
by eckesicle on 5/17/21, 8:29 AM
Software engineers who make active choices in their setup rather than just accept default configurations and tools tend to be better at other aspects of their job too?
by nyuszika7h on 5/17/21, 10:31 AM
* There will always be that one diff tool/website which doesn't support configuring the tab width and renders your code with 8-space tabs. Even if every tool you use supports configuring this, it's going to be a nightmare to configure every single tool when the default of 8 is not sane for the majority of people.
* If you enforce a maximum line length for your code, people who use a different tab width than you are bound to mess this up. I mean, you can somewhat avoid it with an automated linters, but then again, which tab width do you set it for? If you set it too low, it will look bad people with bigger tab widths working on a split screen. If you set it too high, code will be unnecessarily wrapped everywhere and it will look bad.
* Mixing tabs and spaces to ensure proper alignment of function arguments with any tab width can be a nightmare. Someone on your team is definitely going to mess it up eventually, and you'll have to clean up after them. With spaces enforced, indentation and alignment will look the same everywhere and mistakes will be immediately obvious regardless of the tool used for code review. (Editors may support differentiating tabs visually, but I don't think GitHub or GitLab does.)
On a team project, you don't get to choose other things like brace style either. You just have to learn to deal with it. There are too many variables to account for, such as the ones I mentioned above. Using spaces ensures consistency everywhere.
In an ideal world, you wouldn't have to worry about all this, you would just store a minified version of the code and your editor could format it with your preferred tab width, line length, brace style, etc. But in reality, it's not that simple. Auto-formatters are far from perfect.
by FriedrichN on 5/17/21, 8:16 AM
That's my 100% unscientific, non-evidence based guess.
by maury91 on 5/17/21, 8:14 AM
by totalZero on 5/17/21, 8:12 AM
by benrbray on 5/17/21, 8:11 AM
by isitdopamine on 5/17/21, 8:12 AM
by tffgg on 5/17/21, 8:08 AM
by pitched on 5/17/21, 8:07 AM
by paulolc on 5/17/21, 2:50 PM
Developers with visual impairment have different needs regarding indentation. One could need a tab-width of 1 due to the use of gigantic font size and the other a tab-with of 8 because of a wide monitor.
[1] Nobody talks about the real reason to use Tabs over Spaces https://news.ycombinator.com/item?id=20381027 https://news.ycombinator.com/item?id=20341354)
Previous threads https://news.ycombinator.com/item?id=20381027 https://news.ycombinator.com/item?id=20341354
by cryptica on 5/17/21, 8:44 AM
If everyone chose tab spacing sensibly, then tabs would be ideal but there always seems to be some people somewhere who will exploit any flexibility provided by any technology to do something retarded.
At least with 2 spaces, I have full control over how my code looks everywhere.
by vishnugupta on 5/17/21, 8:28 AM
Instead of saying international athletes are more likely to use Nike shoes you end up saying Nike wearers are more likely to be international athletes.
by ybbond on 5/17/21, 8:03 PM
But no, I cannot —even sneakily, manually— enforce tab in my company(es) code bases. Reasonable person uses formatter which opinionated config set from the first commit.
And I like the formatter decision better. If it is automated and reduce unnecessary debate between devs, why not?
by junon on 5/17/21, 10:34 PM
by kodah on 5/17/21, 11:07 PM
by mfbx9da4 on 5/17/21, 8:20 AM
by u801e on 5/17/21, 10:26 PM
by mikewarot on 5/17/21, 7:29 PM
They missed an axis.... sure you can compare Space vs Horizontal Tabs, but what about Line feed vs Vertical tabs? Form feeds are similarly overlooked.
Also missing is the lf / cr-lf debate 8)
PS: Does anyone use Group, Record, or Unit Separators?
Reference: https://theasciicode.com.ar/ascii-control-characters/vertica...
by Yizahi on 5/17/21, 9:18 AM
Personally, I sometimes log onto very old boxes running some old OS and s/w, and I've never seen broken indentation display for tabs.
I think replacing tabs with multiple spaces was a valid solution in 20th century, but not anymore for last decade at least. Instead it transformed into a cargo cult like obsession, with zero valid reasons today.
by dang on 5/17/21, 7:23 PM
Developers Who Use Spaces Make More Money Than Those Who Use Tabs (2017) - https://news.ycombinator.com/item?id=20718031 - Aug 2019 (148 comments)
Developers who use spaces make more money than those who use tabs - https://news.ycombinator.com/item?id=14560042 - June 2017 (663 comments)
by globular-toast on 5/17/21, 8:35 AM
In other sad missed opportunities, see the ASCII delimiters: https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
That's right, four levels of delimiters, built in to ASCII! No unicode required. Instead of that we get CSV, with in-band delimiters and the resulting god awful quoting rules that go with that.
by Stranger43 on 5/17/21, 2:55 PM
If there for instance was an correlation between having lived though the bad old days with primitive build/formatting tool chains and a preference for spaces that would easily explain a difference in salary that have nothing to do with the argument for/against tabs/spaces as it relates to modern tooling.
by hankchinaski on 5/17/21, 9:19 AM
[0] https://www.sciencedirect.com/science/article/pii/S259029112...
by mnd999 on 5/17/21, 8:12 AM
by EVa5I7bHFq9mnYK on 5/26/21, 8:06 AM
by yummybear on 5/17/21, 8:28 AM
by hackerbabz on 5/18/21, 6:19 AM
by mclightning on 5/17/21, 11:00 AM
by trog on 5/17/21, 8:51 AM
by renewiltord on 5/17/21, 7:42 PM
A.k.a The Market Hates Bikesheds
by Ballas on 5/17/21, 9:44 AM
by Threeve303 on 5/17/21, 8:40 PM
by zelphirkalt on 5/17/21, 8:13 AM
by thanatos519 on 5/17/21, 8:15 AM
by jl2718 on 5/17/21, 1:41 PM
Then, a few people started doing tabs and then spaces to indent their function arguments to align with the opening parenthesis of function arguments. Why? Because it looks like a windows drop-down menu hierarchy, opening the sub-menu to the right of the selection. These people tend to be UI-focused, heavy PowerPoint users, CS 101 teachers, and management types.
This was okay when everybody was using MSVC or Visual Basic (no Unix person would do this), and so tabs-then-spaces code crept into everything. Tab purists were at worst mildly annoyed. There was no such thing as a space purist. They would have been physically assaulted for banging on a mechanical space bar that many times in a cubicle office.
But if you opened up that file in notepad.exe, or wordpad.exe, or TextEdit, or Borland or vi or emacs or any other text editor, you would get a preview of the chaos that was about to be unleashed. When the web became popular, the standard programming environment for a lot of people became “right click -> view source”. Space width was all over the place. Tab width was blowing text off the page. Word wrap was horror, and saving a file in word wrap mode saved the imputed carriage returns.
But that was still just aesthetics. When python became popular, it changed behavior. Python tried to adapt by allowing many different styles of indentation. It worked most of the time, but not all the time. This is how it turned into a full-on war.
It is easy to convert tabs to spaces, and hard to go the other way. So naturally, people wrote a simple script to convert tabs to the right number of spaces. Then immediately the number of key bangs rose to a deafening roar. Nerf sales went through the roof as the office became a war zone. The accountants were still using pencil and notebook.
So people tried to write scripts to convert back to tabs. Hahahaha mortal. You can never go back. Your attempts are futile and the one bug you introduce will be your undoing. Foolish tab purist! Come to the dark side and embrace the space. Yesssss... see that giant bar at the bottom of your keyboard? Hit it! Again! Louder! What’s that? You made a mistake? Lost count? Start over! Hahahahahaha!
Then editors changed to no longer record your keystrokes, but instead try to guess at what you mean and show you what it wants you to have meant. These editors have other great features to churn out reams of code that nobody will ever be able to review or keep up with, which is the key to leading a project and getting that promotion. The worse the code, the more people you’ll have to manage to get it working.
Meanwhile, tab purists are an exiled minority, unable to find anybody to work with, begrudgingly accepting their orders from some young superstar coder that blew out the git log in their first 30 days on the job.
Oh the lowly tab purist. Go home and seethe; you are defeated. Watch again one of the five movies you own on your Betamax or HD-DVD. Better standards? Hahahaha!
by King-Aaron on 5/17/21, 8:13 AM
by d--b on 5/17/21, 8:16 AM
by thenoblesunfish on 5/17/21, 11:31 AM
by hpen on 5/17/21, 11:16 PM
by alephnan on 5/17/21, 8:17 PM
by iamgopal on 5/17/21, 8:20 AM
by tmccrary55 on 5/17/21, 8:12 AM
by iovrthoughtthis on 5/17/21, 8:22 AM
is one (or some) high paying companies coding practices skewing the results?
by alanchen on 5/17/21, 11:22 PM
by abcdasfwe on 5/17/21, 8:59 AM
by traceroute66 on 5/17/21, 8:14 AM
by blarg1 on 5/17/21, 9:18 PM
by avipars on 5/17/21, 8:47 AM
by Cerebrum1234 on 5/17/21, 9:17 AM
by wavegeek on 5/17/21, 8:27 AM
a) More smart
b) More correct.
It is not that complex.
Also they are more likely to be using emacs, another big win.
by raverbashing on 5/17/21, 8:12 AM
I don't even know why this is a discussion, if ASCII has a character that represents an indent, we might as well use it (unless you prefer typing & as Et, < as LessThan, etc)
That being said, yes, using spaces for arbitrary alignment is easier