• Linus Torvalds added hidden tabs to Kconfig to challenge parsers that can’t handle them.
  • Tabs were intentionally added to the common Kconfig file for page sizes to expose faulty parsers.
  • Torvalds believes parsers unable to handle tabs shouldn’t be parsing kernel Kconfig files, aiming to force fixes.
  • TCB13@lemmy.world
    link
    fedilink
    English
    arrow-up
    238
    arrow-down
    6
    ·
    2 years ago

    “if you can’t parse tabs as whitespace, you should not be parsing the kernel Kconfig files.” ~ Linus Torvalds

    This is what we got after people sent him into PC training. The OG Linus would say something like “if you’re a piece of s* that can’t get over your a** to parse tabs as whitespace you should be ashamed to walk on this planet let alone parsing the kernel Kconfig files. What a f* waste of space.”

  • Nik282000@lemmy.ca
    link
    fedilink
    arrow-up
    79
    arrow-down
    2
    ·
    2 years ago

    Why would anyone NOT parse a tab as whitespace? Like, python really wants you to use spaces but will still let you use tabs if you are consistent.

    • dinckel@lemmy.world
      link
      fedilink
      arrow-up
      12
      ·
      edit-2
      2 years ago

      Even then, unless for some reason you code on paper, there is no excuse to not have a formatter, that enforces one style, or the other

  • inetknght@lemmy.ml
    link
    fedilink
    arrow-up
    75
    ·
    2 years ago

    I’m honestly on Torvalds’ side here.

    Tabs are a necessary part of the tooling and configuration files. Any tool which doesn’t properly handle files that are correctly formatted for other tools is… a broken tool.

  • tooLikeTheNope@lemmy.ml
    link
    fedilink
    arrow-up
    54
    ·
    2 years ago

    Torvalds believes parsers unable to handle tabs shouldn’t be parsing kernel Kconfig files, aiming to force fixes.

    Stern but just

  • PanoptiDon@lemmy.world
    link
    fedilink
    arrow-up
    53
    arrow-down
    1
    ·
    2 years ago

    Reminds me of Beethoven writing Für Elise for sometime he loved, and when he was rejected, the music was finished in such a way that she could not play it.

  • BigMikeInAustin@lemmy.world
    link
    fedilink
    English
    arrow-up
    36
    arrow-down
    1
    ·
    2 years ago

    I do the same to people who refuse to follow specifications they agreed to follow.

    There is a slight satisfaction to get back at them for continually delivering much lower quality than is required.

    But it really is to cover me. Because, it always happens, later in the future that edge case comes up, and everything breaks. And management is ready to blame me. But then I show them that I tested the edge case before the conclusion of the project. And that programmer ignored my emails, and that I told management these edge cases weren’t covered. But then management signed off on calling it complete. And suddenly management is no longer red with fury. And they usually won’t allow me time to fix it. So the can gets kicked down the road until the next time that edge case fails.

  • merthyr1831@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    2 years ago

    The Register did a good article covering the change.

    Source files should be conservative with the standard they expect from the developer, and parsers should be liberal in what they expect from the source, ie. allow deviations from the standard.

    Python for example supposedly only allows 4 spaces for indentation, but as long as the developer is consistent most if not all Python interpreters will accept any kind of indentation.

    • barsoap@lemm.ee
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      2 years ago

      Python for example supposedly only allows 4 spaces for indentation, but as long as the developer is consistent most if not all Python interpreters will accept any kind of indentation.

      That’s a recipe for disaster as your syntax is under-specced. You’re right-up inviting programmers to produce programs with implementation-defined semantics.

      Haskell (which also uses layout syntax) never had that problem as tabs were simply defined to be eight spaces, but that then led to issues with people setting different tab-widths in their editors and a flurry of syntax errors when they did “tabs for indentation, spaces for alignment”. Which is why Haskell then moved ahead to outlaw tabs, I think it’s still in the “throw a warning” phase but at some point it’s going to be a hard error.

      That’s not to say that kconfig should do the same – presumably they used tabs for a good reason, and all those other programs are simply not following the spec. Essentially including unit tests in the actual production files is a good move when you’re dealing with that kind of situation.

      • UndercoverUlrikHD@programming.dev
        link
        fedilink
        arrow-up
        5
        ·
        2 years ago

        Eight space indentation should be crime, I’m not made out screen width over here.

        If you want to be strict with indentation, use tabs as your standard instead of forcing others to use your preferred visual width.

        • barsoap@lemm.ee
          link
          fedilink
          arrow-up
          1
          ·
          2 years ago

          Eight is still the default tab width and will be as long as VT100 continues to be a thing, i.e. forever. Haskell could’ve chosen another static value but that would have caused even more trouble.

          With Haskell’s syntax you really want to align at single-space resolution, not necessarily just on the left but also further to the right, within the lines. The gold standard is pretty much lhs2tex “poly” style (section 8, page 19), and not just because it allows lhs2tex to spit out beautiful code, it’s also highly readable in ASCII form. In that style 2+ spaces mean “align this with the 2+ space stuff above and below”.

          So there’s no way around spaces and as tabs+spaces are a bad idea tabs get the boot. That argument is specific to Haskell but in general I’d argue that tabs are more trouble than they’re worth – if you have trouble editing space-only indentation, get a proper editor. If I want my Rust indented by a different amount I can just tell rustfmt to change everything, no biggie.

    • Subverb@lemmy.world
      link
      fedilink
      arrow-up
      3
      arrow-down
      3
      ·
      2 years ago

      Having a language dependent on indentation is absurd on the face of it. It’s a ridiculous idea that should have been ridiculed from the outset.

      • barsoap@lemm.ee
        link
        fedilink
        arrow-up
        2
        arrow-down
        1
        ·
        2 years ago

        No. Having a language depend on semicolons even though there’s ways to do without, ways that don’t even include layout if you don’t want to, is well not absurd on the face of it it’s hysterical raisins.

        Haskell has one of the most admired syntaxes out there, and it’s layout. It’s clean, predictable, very simple and most of all intuitive rules. It makes sure that semantic structure always follows visual structure, thus provides a single source of truth why Algol-likes (i.e. everything that looks at least vaguely like C) have two.

        I don’t indent my Rust, I let rustfmt do that. All that automation and I still get into lots of missing or mismatched braces situations which literally never happen in Haskell because the structure of the program is visually obvious, you don’t have to look for tiny squiggles to figure out what it is.

  • Avicenna@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    2 years ago

    I am no kernel or parsing expert here but how hard would it be to convert tabs to spaces? Is it like very finicky and is weirdly platform dependent that it wouldn’t just be one of the first things that you do if you are writing a parser for anything?