• expr@programming.dev
    link
    fedilink
    arrow-up
    3
    arrow-down
    1
    ·
    8 months ago

    This is simply false, many systems have them configured by default to 8, particularly most CLI tools. Git, for example, is 8, and btw, changing it is not readily done and requires you to hack around it by using a custom pager command. In fact, all core gnu utils (and even bash itself) default to 8, as well vim, emacs, nano, gedit, etc.

    I use 2 spaces since I work in Haskell, which is a significant whitespace language where you want certain syntactic constructs to exist at a different level of indentation from your main code block. So yes, I have configured it. 2 spaces is also exceedingly common for HTML (browser Dev tools renders HTML with 2 spaces, even).

    There is not a universal indentation width, though it is almost always universal within a particular language or perhaps project, in which case it’s much better to have everything standardized. Code formatters enforced on a project are the norm, and those are way more impactful on how the code is read. But they are valuable because consistency is valuable. And yet, somehow you don’t have huge scores of developers complaining about being forced to format their code in a way they don’t like.

    As I said, you don’t necessarily control the environment in which you are viewing code. A common example is reading code over a shared screen. So you can easily end up reading code in a way you don’t like anyway, so it may as well be some reasonable (if not preferable) standard that everyone is using.

    • Traister101@lemmy.today
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      edit-2
      8 months ago

      Looking at code on somebody else’s screen is entirely missing the point of using tabs over spaces. The entire point is that mine looks like how I want and theirs looks like how they want even though the file is identical. We can each have wildly different tab width and it’ll look wildly different to each of us when we program. That’s again the point.

      Code formatters are great! I love them. Using tabs over spaces is objectively a better formatting option. One of my favorite features in code formatters is that they’ll swap out spaces to tabs for you insane people who insist on mashing the space bar to indent.

      • expr@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        8 months ago

        Umm, you do realize no one manually enters all of the spaces, right? Basically all editors support an expandtab feature which inserts the amount of spaces you want whenever you hit the tab key.

        Code formatters behave exactly the same regardless if you’re using tabs or spaces, so not sure what you’re talking about.

        I did not miss the point. I fully understand that’s why people want tabs. I just think it’s a pretty stupid and petty reason to make for a worse experience when viewing code in places you don’t control. I still don’t know why using spaces is an issue when we enforce standards in literally every other facet of contributing to a codebase. We enforce coding styles. Indentation is part of the coding style.

      • lemmyng@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        8 months ago

        No, it’s not missing the point. The premise that you’re always looking at code on the same screen is false, and you don’t always have control over how all screens are configured.