• redempt@lemmy.world
    link
    fedilink
    arrow-up
    9
    arrow-down
    3
    ·
    1 year ago

    why don’t we store code unformatted and have everybody’s IDE display it with their preferred format applied? it would make everything easier and stop people bickering over pointless things.

    • Ashtefere@lemmy.frozeninferno.xyz
      link
      fedilink
      arrow-up
      21
      arrow-down
      2
      ·
      1 year ago

      That’s what tabs are for. 1 tab, to an ide, means “you choose how many spaces this tab is, and when we commit it back to git it won’t fuck the history up.”

      • maor@lemmy.org.il
        link
        fedilink
        arrow-up
        5
        arrow-down
        1
        ·
        1 year ago

        I guess they were referring to formatting other than tabs, like place of brackets and line length, which sounds like a neat idea

        • dukk@programming.dev
          link
          fedilink
          arrow-up
          6
          arrow-down
          1
          ·
          1 year ago

          …until you start using languages where whitespace is the only way to distinguish code blocks. (Most notably Python.)

          • aes@programming.dev
            link
            fedilink
            English
            arrow-up
            2
            ·
            1 year ago

            It was harder to explain why picking on Python for this is dumb, before gotofail… (Not saying that’s what you’re doing, but it feels close, so this is relevant.)

            For whitespace, my rule is this: If any level of indentation depends on the length of any word or name, you’re doing it wrong. If using a more descriptive name causes indentation where previously there was none, that’s fine, but if moving the opening parens causes the interior to be indented more, less so. (Yes, Golang’s structs)

    • moomoomoo309@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Storing an AST would be interesting, but it’d require the IDE to support parsing each specific language, so you’d probably want something like an LSP but for just parsing to handle that.