10 ms·
Linus Torvalds adds arbitrary tabs to kernel code
- rickdeckard 3y agoParser fails to parse data --> Fixed by modifying ingested data Just that the ingested data is a part of the Linux kernel codebase. Quite some hubris to proceed and apply such a "fix" by making a commit to the Linux kernel...
- IncreasePosts 3y agoThe author and committer are two separate people, so it isn't like one person unilaterally submitting this.
- bjackman 3y agoArguably it would be fine if the community benefited from the parser. After all it's just a custom, undocumented format that lives specifically in this one repo. But I totally sympathise with Linus' annoyance when the issue is with an external tool, and the author didn't explain which tool or give any reason why it's hard to fix that tool.
- karma_pharmer 3y agoThe nom_kconfig crate has tabs-vs-spaces bugs too. Unfortunately until somebody spends the time to create a Kconfig test suite, the kernel itself needs to be the test case for this oddity. https://docs.rs/nom-kconfig/latest/nom_kconfig/ https://docs.rs/nom-kconfig/latest/nom_kconfig/
- cqqxo4zV46cp 3y agoYou cant use “hubris” as a pejorative and go on to claim that Linus is the good guy. There’s clearly hubris on both sides, and only one of the sides made a big deal about it. Developers change things for parsers all the time. That’s, like, coding.
- Brian_K_White 3y agoIncorrect. It's only hubris on one side. It's both Linus's plain arbitrary right, and his plain job, his defined role and office, to make exactly such decisions for this project. That's not hubris. It's just a role that affects a lot of people. What makes it hubris on one side is "Who do you think you are making such a change to the Linux kernel that everyone else will have to accept?" The reason things like that are phrased as questions is to allow for the possibility that there might be an answer. For one of these parties, the question is rhetorical. For one of these parties, the question is not rhetorical.
- halJordan 3y agoYou're misunderstanding the statement (probably because of hubris). Linus has a long tail of hubris-informed acts that have been blessed off, accepted, and rationalized. No one is saying this particular rejection is one of those: Just that if it's ok for Linus to be full of hubris (and it incontrovertibly is) and then it cant be a criticism of this guy either.
- ikekkdcjkfke 3y agoHubris implies over-confidence, this dude has the skills and knowledge
- Brian_K_White 3y agoHubris is overreaching. Linus is not overreaching. His reach actually is farther than yours or mine, and this act and most others are not hubris. It's not even being full of himself.
- rickdeckard 3y ago
- dustypotato 3y agoThe guy could've just said it was a minor formatting change and had a better chance of getting the PR approved, instead of presenting the nonsensical reason (the parser)?
- isatty 3y agoWhat do you mean? Reading the email exchange it looks like Linus pulled the commit and the committers description was accurate. The tabs were then added back which I also think was the right thing to do.
- mvkel 3y agoBut changing the tab to a space violated the clearly defined style guide for the kernel, so it wasn't an acceptable change
- david_allison 3y agoCommit in question: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d5cf50dafc9dd5faa1e61e7021e3496ddf7fd61e https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...
- slaymaker1907 3y agoLol, the commit message is just great https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d5cf50dafc9dd5faa1e61e7021e3496ddf7fd61e&dt=1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin... It's good that Linus is really exercising those 3rd party tools! They should send some money his way for helping them test their code.
- sampo 3y ago> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d5cf50dafc9dd5faa1e61e7021e3496ddf7fd61e&dt=1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin... This web view renders tabs as spaces, so it's not possible so see what was changed.
- infogulch 3y agoThese are a bit easier to see what's going on: https://github.com/torvalds/linux/commit/d5cf50dafc9dd5faa1e61e7021e3496ddf7fd61e?diff=unified&w=0 https://github.com/torvalds/linux/commit/d5cf50dafc9dd5faa1e... https://github.com/torvalds/linux/blob/d5cf50dafc9dd5faa1e61e7021e3496ddf7fd61e/arch/Kconfig#L1175-L1180 https://github.com/torvalds/linux/blob/d5cf50dafc9dd5faa1e61... Unfortunately Github doesn't have a way to render symbols for whitespace, but you can tell by selecting the spaces that the previous version had leading tabs. Linus changed it so that the tokens `default` and the number e.g. `12` are also separated by a tab. This is tricky, because the token "default" is seven characters, it will always give this added tab a width of 1 char which makes it always layout the same as if it were a space no matter if you use tab widths of 1, 2, 4, or 8.
- lionkor 3y agoPeople use tab width of 3 ;) just to keep us on our toes
- sampo 3y agoIndentation by steps of 3 spaces is common in old Fortran 77 code. This is LAPACK for example. Scroll down to about line 400 to see actual code, not comments. https://github.com/Reference-LAPACK/lapack/blob/master/SRC/cbbcsd.f https://github.com/Reference-LAPACK/lapack/blob/master/SRC/c...
- seventytwo 3y agoWhy would anyone use spaces?
- XorNot 3y agoBecause spaces are guaranteed to layout the text to a predictable format, whereas tabs are not since the size can be adjusted and tab-stops don't necessarily line up with obvious word boundaries on the lines above.
- Dibby053 3y agoThe correct way to use tabs is to indent with tabs and align with spaces, that way everyone can adjust the tab size to their liking without breaking alignment.
- MrJohz 3y agoThen you've got mixed tabs and spaces, which seems like it's going to inevitably lead to confusion when someone who isn't aware of the convention starts to make changes. Two different invisible characters in a single file is a recipe for madness.
- yencabulator 3y agoBy your definition, all Go code in the world is madness? Newbies editing code is a problem best solved with automatic formatting.
- smallstepforman 3y ago“correct way”? This is just your opinion. Everyone has one. Want to read mine? “A text editor should never replace what I type”. Want another opinion? “An editor should always distinctively display white-space characters”.
- okanat 3y agoThat doesn't work when alignment depends on the tab size like aligning an indented line below an unindented line like long assignments Type myvar = something_very_long + that_needs_alignment; The only way to guarantee such complex alignment is using spaces. It renders everywhere exactly the same. So reviewing stuff on web-based environments gets easier.
- deleted 3y ago[deleted]
- floobertoober 3y agoThis seems very reasonable, similar to GREASE with tls.
- deleted 3y ago[deleted]
- andrewmcwatters 3y agoThere's only two ways to write code where the lines of text stay legible regardless of tab size configuration: 1. Use all spaces 2. Use tabs for indentation and spaces for alignment Unfortunately, only individual developers seem competent on their own to do #2, so everyone who cares about readability inevitably practices #1 by default. You can never use only tabs.
- saghm 3y ago> Use tabs for indentation and spaces for alignment I'm not surprised that this isn't something that projects have been able to adopt successfully very often because I've never found it very intuitive that those are separate things. In what way is "indentation" not also a form of "alignment"?
- deleted 3y ago[deleted]
- zarzavat 3y agoThe other problem with it is that it assumes that people have visible whitespace on, and that their tools even have that option to show whitespace, otherwise it’s like navigating the Fuchsia Gym. I don’t mind if people use tabs but mixing the two is not great.
- yetihehe 3y agoThe worst mixing I've seen: aligning on 4 spaces, but using tabs as a placeholder for 8 spaces. So first stop is 4 spaces, then tab, then tab and 4 spaces. Chaotic evil version of tabs vs spaces battle.
- yencabulator 3y agoWhy would you care about the whitespace? Formatting is a job for computers, not humans. I'm practically unable to `git add` unformatted Go or Rust code, and very happy with the setup: .config/git/attributes: *.go filter=gofmt *.cgo filter=gofmt *.rs filter=rustfmt .config/git/config: [filter "gofmt"] clean = "gofmt" [filter "rustfmt"] clean = "rustfmt --edition=2021"
- hedora 3y agoObligatory not-xkcd: https://www.reddit.com/r/programming/comments/p1j1c/tabs_vs_spaces_vs_both/ https://www.reddit.com/r/programming/comments/p1j1c/tabs_vs_...
- vanderZwan 3y agoReplace the third guy with "tabs with editor configured to three-space width" and you have an accurate representation of my experience. I don't get why it gets so many people upset, even though it's obviously the sweet spot for visually distinct indentation and minimal actual indentation (not my own idea, I think the elastic tab-stops guy suggested it in one of their blogs). The last time I mentioned this on mastodon someone responded what I consider the best possible way to answer to all of this: > The optimal tab width is e. It's wide enough to be obvious, but not so wide as to reduce line length too much. Plus, it discourages the use of tabs for alignment by being the number most difficult to approximate with any integer number of spaces. ... and when I say "best possible way" I mean "trolls everyone while making a solid point" [0] https://mathstodon.xyz/@andrewt/110448426042547762 https://mathstodon.xyz/@andrewt/110448426042547762
- jraph 3y agoDiscussion here from two days ago: https://news.ycombinator.com/item?id=40043110 https://news.ycombinator.com/item?id=40043110
- quectophoton 3y agoThankfully there's a trend of new programming languages including their own formatters, thus solving the problem once and for all.
- cherryteastain 3y agoLinux, as a project, could also decide ro require every patch to be formatted via clang-format. They just don't.
- karma_pharmer 3y agoThankfully there's a trend of excessive merge conflicts caused by reformatters. Reformat-on-every-commit really only works for highly-centralized, tightly-coupled, monorepo-using monolithic organizations. Basically the exact opposite of kerneldev. For those folks reformat-on-every-commit works great.
- em-bee 3y agoactually, what we want is code management tools that work with tokenized code and do not depend on formatting. i want a diff tool that shows me exactly which tokens have changed, and which haven't, regardless of how they are laid out. when we get that, then we should get even less merge conflicts.
- jasomill 3y agoAnd I'd prefer a system with an AST as the canonical representation, allowing each programmer to set their own display formatting options entirely independently of the underlying codebase. Realistically, either of these options would only really work for tools and codebases designed with these workflows in mind, as they'd be useless for inputs to inherently text-based tools like the C preprocessor.
- karma_pharmer 3y agoallowing each programmer to set their own display formatting options entirely independently of the underlying codebase. That's the easy case. The hard case is situations where the formatting (whitespace, etc) is not simply some deterministic function applied to the AST. For example: comment placement and tabular layout of repetitive constant definitions. Or situations where vertical alignment is used to call out parallel structure. Mathematicians have been using horizontal alignment to call out important structure in equations (both written and typeset) for hundreds of years. Here's are two examples if you don't know what I'm talking about: https://kagi.com/proxy/ILVap.jpg?c=085W0W0Vgv9kix8Uo-TAMYM_FT1u23UFqHfiq4zyoC7SNFxXinp9WqjiTM14lkaA https://kagi.com/proxy/ILVap.jpg?c=085W0W0Vgv9kix8Uo-TAMYM_F... https://kagi.com/proxy/Zr5re.png?c=085W0W0Vgv9kix8Uo-TAMb-ZJ9tlIOckKNxTWVDXFV8DwbMWKEFKbX9zuX2S1K7U https://kagi.com/proxy/Zr5re.png?c=085W0W0Vgv9kix8Uo-TAMb-ZJ... The people who stubbornly insist that programmers have no need for this sort of expressiveness seem like innumerate cavemen, frankly. They cheapen our field, reducing it from informatics to mere keyboard labor. The urge to run code formatters is a "language smell" indicating that your language has way, way, way too much odd and irregular syntax. See Haskell for a counterexample. Sure, there are a few code formatters for Haskell, but nobody really uses them. The language's syntax is so minimal and clean that there just aren't all that many preference-based choices to be made.
- Brian_K_White 3y agoAwww did your 3rd party tool bump it's widdle nose on a tab? There there, mommy will make it all better...FIREHOSE OF TABS
- 10g1k 3y agoSignificant whitespace in any language or system is a mistake. Just exclude spaces, tabs, and newline special characters.