7 ms·
This seems fairly straightforward to me. If you're collaborating, spaces are a much better default. If you're collaborating, your job is harder than coding sol
by passive 9y ago
This seems fairly straightforward to me.
If you're collaborating, spaces are a much better default. If you're collaborating, your job is harder than coding solo, so you should get paid more.
- jimmaswell 9y agoI work on collaborative projects, some use spaces or tabs and it makes no difference to the ease of collaboration. It's just a setting in the .editorconfig.
- Peaker 9y agoIn all collaborative projects I've been that allowed tabs, all files that had been edited by tab users were a mishmash of spaces and tabs that made no single tab width configuration workable. If you chose tab width as 4, some parts of functions would look right, others would have messed up indentation. Ditto for any other tab size. The theory of tabs for indent and spaces for alignment works. But when collaborating, the practice requires too much support from tooling and too much education for humans -- so it's just not worth the tiny benefit.
- biggieshellz 9y agoSeems to work OK for the Linux kernel, and the tooling is not onerous -- just run checkpatch.pl on your commits before pushing them upstream.
- user5994461 9y agoThe kernel has an official & mandatory rule to enforce tabs, at a length of exactly 8 spaces per tab. Anything that doesn't respect that will be rejected without mercy.
- Veedrac 9y agoThat's not a fair comparison. You either disallow tabs, or you disallow spaces. A mismatch isn't either, so it doesn't evidence either being better than the other.
- dxhdr 9y agoDisallowing spaces isn't an option, you can't align code using tabs. You have to both disallow spaces and enforce a no-alignment (leading-indent-only) formatting style. Just use spaces! You can't mess it up. ;)
- jimmaswell 9y agoMeticulously lining code up like ASCII art seems like an antipattern to me nowadays. It might make some regions of the code look a little bit nicer, but it's never really strictly necessary and it comes at the cost of higher maintenance - for example, add to that list of assignments with lined up equals signs and you have to make your addition line up too, and if your variable name is longer than the longest one in the list so far you have to move all the previous ones over.
- Veedrac 9y ago> Just use spaces! You can't mess it up. ;) Oh how I envy someone who can say that.
- jimmaswell 9y agoThen just run an autoformatter over the whole codebase once and clean up anything that looks wrong as you come across it later.
- itaris 9y agoWhat do you mean? If some devs are using spaces, and some tabs, wont that create pretty unpleasant whitespace differences?
- lostapathy 9y agoIt does, and it's awful. In theory it would work out ok. In practice, people use different tab widths, and don't always notice they are "wrong" when doing a quick change. Next thing you know, you've got spacing like your tab width should be 2, 4, and 8 spaces and you really have a mess.
- creepydata 9y ago>don't always notice they are "wrong" when doing a quick change. I can't understand this! First thing I do when I open up an editor is show whitespace characters. They are part of the source code this should be always be displayed! It would feel wrong to code without showing whitespace. If you can see your whitespace you can tell right away that it's wrong.
- thealfreds 9y agoPfft I just cmd + alt + j every file I touch. Everyone must conform!
- bryondowd 9y agoIs this[1] what you're referring to? That sounds like grounds for summary execution to me. My group had me write a git commit hook that demands all source files pass a dry-run of astyle before you can commit. It'll let you view the difference and either cancel the commit and fix it yourself or just take the auto-formatted by astyle version and commit that. [1] https://kau-boys.com/1128/shortcut/shortcut-of-the-month-ctrl-alt-j-eclipse https://kau-boys.com/1128/shortcut/shortcut-of-the-month-ctr...
- jimmaswell 9y agoDifferent teams, not different indentation within the same team.
- passive 9y agoI'm glad you have a system that works for you and your collaborators. :) But you've also pointed out a cost to what you are doing. If everyone adopted one or the other, you wouldn't need an .editorconfig setting. You've increased the burden of collaborating with you by requiring a particular configuration setting.
- jimmaswell 9y agoIt's a single file placed at the root of the repository. The text editor/IDE will automatically see it and silently apply it as you edit the file (eg press tab and it inserts x spaces or a tab, uses whatever newline specified). There is no extra burden unless you need to download a plugin for it manually.
- Tyr42 9y agoDoes ag read it automatically so search results are well formatted? git diff?
- btilly 9y agoTabs users frequently claim that. But when I start running diff, less, and so on, I'm left with the conclusion that every tool has to be configured in a separate way for every user, in every environment. And this makes their code a PITA to deal with. I'm generally not the one to complain. And I'll still use tabs if that is the standard for the code base that I'm working with. But tabs are strictly worse, and your flippant answer won't particularly please people that you need to collaborate with.
- jimmaswell 9y agoThe indentation style was like that before I got there in each case. One just uses the Visual Studio default settings, the other is default Visual Studio settings but with tabs. I've never run into an issue with diffs or anything like that.
- spinlock 9y agoThis is how I feel about it too. Tab users seem to be saying that, with their configuration of vs-code, tabs work fine. I like a format that works fine with cat, sed, grep, and all of the other unix utilities in my githooks. plus, I can run vim on a terminal on my phone. vs-code isn't there yet.
- jimmaswell 9y agoExactly what problems are you having with grep/git and tabs? Grep has \s to match any whitespace character and git has settings to ignore whitespace.
- btilly 9y agoThe default display for every tool is 8 spaces for a tabstop. If you don't want that, then each tool has to be configured separately, with a different method for each. Many require a command line option (which one differs by tool) that has to be typed in each time. Yes, you may not notice or care. But if you're told about why other people don't like it, and dismiss them with flippant answers, you're going to make those other people unhappy. Remember that the key to successful collaboration is to be strict in what you emit, and generous in what you receive. No matter how unreasonable you think the other is, in this case you're failing as well.