• xigoi
    link
    fedilink
    451 year ago

    Tabs let you define how big you want each indent to be

    …except when they don’t. Many common environments have a hardcoded tab size of 8, which is insanely big for using it for indentation.

    • z3bra
      link
      fedilink
      411 year ago

      Because other people might have restricted environment which might not suit their preference is not a good reason to level it down IMO.

      Also, I think 9 is the best size for indent (matter of preference), do you think I should switch to space so everyone can enjoy this wonderful view I have ?

      • xigoi
        link
        fedilink
        41 year ago

        It’s not just “might”. Termux is pretty much the only good choice for programming on Android.

        I think 9 is the best size for indent (matter of preference), do you think I should switch to space

        I think you should switch to an exorcist.

        • z3bra
          link
          fedilink
          31 year ago

          What’s your point ? You can use vim on termux and set the tabsize to whatever you want for example.

          • xigoi
            link
            fedilink
            1
            edit-2
            1 year ago

            Yes, but if you use something like cat, head, less, etc. to view code, or the Python REPL, you’re still going to see the default tab size.

            • z3bra
              link
              fedilink
              21 year ago

              You can set the tabstop with less -x*n*. But ok I see what you mean. I still stand by my point though. If termux doesn’t support setting tabstops and it’s an issue, then it’s a bug in termux, not a reason to level down your formatting standard.

          • @MajorHavoc
            link
            11 year ago

            Also :exorcise is only a quick pluginstall away, anyway. /s

    • @[email protected]
      link
      fedilink
      211 year ago

      What environment are you using that has a hardcoded tab size? I haven’t seen this since typewriters.

      Some projects just use tabs as a compressed form of 8 spaces. But that is a sin. Use tab to mean “one indent level” and align with spaces if you need to. (the occasional ASCII art diagram)

      • xigoi
        link
        fedilink
        61 year ago

        What environment are you using that has a hardcoded tab size?

        • Termux
        • SourceHut
        • “View page source” in the browser
        • @[email protected]
          link
          fedilink
          15
          edit-2
          1 year ago

          Termux

          I think running tabs -N (where N is you preferred tab size) in the terminal should work. This is what I use in my zshrc on desktop.

          SourceHut

          Yup, they seem to be pretty opinionated here. If you look at the source there is just an inlined style with a single rule pre { tab-size: 8 }. I guess that is what you get when you use opinionated tools. The user’s browser isn’t right, my preference is right!

          “View page source” in the browser

          On Firefox this uses my default tab size of 4. But I guess changing this default isn’t user-friendly.

          • JackbyDev
            link
            fedilink
            English
            11 year ago

            You can’t count it as good when it is unconfigurable when it happens to use your preference when the whole selling point of tabs is that they’re configurable.

            • @[email protected]
              link
              fedilink
              41 year ago

              I don’t understand what you are trying to say. I agree that SourceHut forcing their preference isn’t good. The other two are configurable and I have configured them to my preference on my machines.

              • JackbyDev
                link
                fedilink
                English
                01 year ago

                You made it sound like Firefox wasn’t configurable, my bad. I thought you were saying you didn’t care that it wasn’t configurable because you liked the width they chose.

                • @[email protected]
                  link
                  fedilink
                  51 year ago

                  Oh no. It is configurable, although it requires editing userContent.css. So barely configurable. I think it defaults to 8 but I reduce it to 4.

      • @[email protected]
        link
        fedilink
        English
        31 year ago

        What environment are you using that has a hardcoded tab size?

        Microsoft Windows’ Notepad. I have sometimes used that when on a public computer.

    • @[email protected]
      link
      fedilink
      131 year ago

      As an embedded software developer that does linux kernel drivers I’ve come to love the tab size 8 indentation level.

      I’m paraphrasing: “if your indentation level gets too deep, it’s time to rethink/refactor your function.”

      And with tab 8 you’ll notice it rather quick if your function does too much/unrelated stuff.

      A function should be short and do one thing only, if possible. It also makes unit testing easier if that’s a requirement.

      • xigoi
        link
        fedilink
        -11 year ago

        When you’re operating on such a low level of abstraction, it’s no wonder you don’t need deep nesting.

        • @[email protected]
          link
          fedilink
          11 year ago

          Oh, I’ve done my fair share of C++ and Python as well. But you got to agree with me that when you are on your fourth indented “if case” it’s time to step back and think about what you are trying to achieve. I mean it’s probably going to work, but probably also very hard to maintain that type of code.

          • xigoi
            link
            fedilink
            21 year ago

            How would you implement, for example, Gaussian elimination with at most 3 levels of nesting?

              • xigoi
                link
                fedilink
                2
                edit-2
                1 year ago

                Be specific. Which exact part would you abstract away and how?

                • @[email protected]
                  link
                  fedilink
                  3
                  edit-2
                  1 year ago

                  There a many ways to implement abstractions, but it’s highly dependent on the language in question. You could simply refactor each level of nesting into its own function, with all dependents provided as parameters instead of scoped variables. You could then flatMap to avoid a bunch of nested looping, favoring a linear approach that’s often easier to reason about. You could go all out and refactor all your conditional statements away, in favor of the Either monad. You’d then have a number of functions, each doing one thing (including no nesting), and a main function gluing it all together, linearly. That is a pattern you can always apply; there’s nothing controversial about it, and on a similar note there’s nothing particularly challenging about Gaussian elimination.

    • JackbyDev
      link
      fedilink
      English
      101 year ago

      This is the biggest problem with tabs. Too many tools don’t let you adjust the size (or make it very difficult). This is the only reason I usually prefer spaces (only very slightly).

      My dream solution is elastic tabstops and I’ve posted about it here before a few months ago. The problem with wanting elastic tabstops is that it seriously compounds the issue of “editors don’t properly support it”

      https://nickgravgaard.com/elastic-tabstops/

  • @[email protected]
    link
    fedilink
    371 year ago

    Another accessibility reason for tabs: when using a braille display, each space takes up one character cell, so indenting with four spaces eats up four cells. Indenting three times with four spaces each eats up 12 characters already. Tabs only take one character cell each, so three indents = three character cells used.

    The fact that there (I assume?) isn’t a braille oriented text editor that can handle space-based indentation in a smarter way is a bit depressing. Maybe the solution should be better tools based around accessibility rather than convincing everyone to switch to tabs, which is a project that will just never succeed.

    • @[email protected]
      link
      fedilink
      121 year ago

      So your fix is “convince all the people that want/need the better handling to use a specific editor?” - perhaps it’s a smaller number of people, but do you not see the irony there?

      I honestly don’t care about tabs vs. spaces, but if there’s a low cost change in my setup that makes it easier on others, why not?

      • @[email protected]
        link
        fedilink
        151 year ago

        My spontaneous reaction is that making some sort of braille oriented setting for some or hopefully most editors used by people with braille displays (I have no idea if using a “normal” editor even makes sense if you’re using a braille display) is the most pragmatic solution to their screens being taking up by spaces.

        First of all, convincing everyone to use tabs is a monumental task. Convincing people with braille displays to use more convenient tools on the other hand seems pretty easy, why wouldn’t you want to use more convenient tools?

        Secondly, there is a large amount of code written with spaces today, so even if people switch with tabs in the future you might still want to be able to read legacy code.

        Thirdly, I don’t think that the choice of tabs vs. spaces is completely arbitrary because of alignment. Using tabs for indentation and space for alignment leads to a lot more micro management of whitespace compared to just using spaces. I would guess that alignment isn’t very braille friendly anyway, but it does make the code more readable for other people. Having a good braille editor affordance might be closer to letting us have our cake and eat it too.

        Of course, I don’t know what this would look like exactly, and maybe there’s some sort of obstacle that I’m overlooking, I do want to be clear that this is just of the top of my head as someone who has never used a braille display.

        • @[email protected]
          link
          fedilink
          01 year ago

          There’s a difference between doing something that’s “easier” and what’s right.

          Whether there is more legacy code with spaces or tabs is irrelevant. Most of the code that will be written hasn’t been written yet.

          I disagree with you on “micromanagement” of spaces vs. tabs, that is nonsense. Set up a formatter for commits and set your IDE to display how you want.

          The pragmatic view on one or the other is that for a one group of people, using tabs appears to be significantly better, and for everyone else, it barely matters at all, except as personal preference.

          That being said, I’m not vision impaired, so I don’t know what the preference would be.

          The reason we’re even talking about it is that someone that has studied it from an accessibility perspective has asserted that tabs would be preferred.

          • @[email protected]
            link
            fedilink
            61 year ago

            There’s a difference between doing something that’s “easier” and what’s right.

            The way I see it, there are two competing strategies for improving the experience for braille screen users: making tabs more widely used and improving braille oriented editors. Without knowing for sure, my guess is that improving editors is a better strategy and this is in part because it is easier.

            As a matter of principle it might be “more right” for people without visual disabilities to adjust themselves to people with visual disabilities than vice versa, but I also think that it’s important to care about what is actually likely to improve braille screen users experience and not default to the more principled goal without any consideration for how realistic it is.

            (Of course, I might be overestimating how easy it is to get better braille oriented editors, but since you referred to this as the “easy” solution it doesn’t sound like you’re disputing this specifically.)

            • @[email protected]
              link
              fedilink
              English
              31 year ago

              Of course, I might be overestimating how easy it is to get better braille oriented editors

              A braille display traditionally is a personal, almost handfitted (estimated by price) device controlled by its screen reader software. Not the editor. This has some unfortunate implications:

              • There is no (standardized) API to control your braille device directly. You could hand your screenreader filtered data, but that would be read as well. At best, you might be able to script your screen reader software to a varying degree of success. However:
                • Every aspect about this is extremely abysmal in every possible way, so it will likely require you to fork over some biiiiig amount of cash to one of the vendors to provide a brittle plugin. In particular if we are talking about JAWS. Think of extremely unstandardized COBOL dev with less stability and more price gauging involved.
                • As far as free readers are involved, only the proprietary and licensing aspect go away. Still, developing extensions is terrible in many ways. For example, for ORCA, I was able to find out that you can extend it somehow. Alledgedly. NVDA on the other hand has better documentation. That is to say, it has documentation. Now, you might recall that NVDA is written mostly in Python, and its devs rightly don’t even pretend that one could develop stable software in Python, so APIs might change. However, I wasn’t able to find a Filter function specific to braille output. That’s likely because
              • From my superficial experience, developers of screen readers think of braille displays mostly as an alternative to speech. It even took them quite a while to be smart about not displaying redundant, long lines of text.

              So yes, you might be overestimating how easy that is, compared to telling some diva asswipe chucklefuck to use that formatter or work at McDolans.

              • @[email protected]
                link
                fedilink
                31 year ago

                Thank you for the insight, didn’t expect it to be that dire. Tabs and spaces nonwithstanding, hope that the screen reader/braille display tooling situation improves in the future, sounds like it is sorely needed.

                • @[email protected]
                  link
                  fedilink
                  31 year ago

                  I sure hope so, but I’m not overly optimistic tbh. The market is basically considered medical, therapeutic devices. It is as you imagine, probably worse. It isn’t easy to find prices directly, but the only way this range of vendors continues to exist in this niche market is to sell devices with the complexity of a keyboard for four to five digits. There is no competition worth talking about happening.

                  So unless very specific regulation takes place, I don’t see standardized access to braille displays happening.

            • @[email protected]
              link
              fedilink
              01 year ago

              Let’s agree that we aren’t going to affect this change in this comment thread, so which one is more “pragmatic” is beside the point.

              What does matter is whether we decide to have an inclusive view on this issue, and are willing to make extremely minor modifications to our settings and workflows to be more accommodating for others.

              I am encountering more and more cases where people behave in inexplicably selfish ways, and this just feels like another one. It’s low/no-cost to do, yet could yield benefits to others. Low cost/risk, high potential reward.

              Starting with “we’re not going to even consider raising awareness and let the market decide” is just a very cynical way to approach the world, and I’d argue is even actively harmful to the people that hold that view.

              • @[email protected]
                link
                fedilink
                3
                edit-2
                1 year ago

                Do you think it matters if getting a large number of people to switch to tabs is an achievable project at all? Maybe I am a bit cynical but this seems to me like something that is actually very difficult to do.

                When faced with a problem like this I think it makes more sense to approach it from a perspective of what would be a practical way to actually address it and refusing to do that does I think in its own way betray a different kind of cynicism.

                For the record what I’m saying isn’t that I wouldn’t switch to tabs for the sake of people with various disabilities, I’m saying that spaces are slightly better than tabs if you don’t have any relevant disabilities so if there is a way to have the cake and eat it to that would be a nice bonus, but that’s honestly besides the point.

                • @[email protected]
                  link
                  fedilink
                  21 year ago

                  You are treating this as a binary/zero-sum game. Will we get to 100% use of tabs (or spaces)? No. Will we get a “perfect” viewer made and then adopted by all visually-impaired people? No. Making people aware that a fairly mundane choice has a negative impact on others might change their behavior, or at least challenge it.

                  Change like this is incremental, so just having the conversation, and asking you to consider that making a small change to your config might help some people down stream is something. Asking you to bring this point to the next conversation about tabs vs. spaces, is helpful.

                  I’m saying that spaces are slightly better than tabs if you don’t have any relevant disabilities

                  This is my fundamental issue with your original statements, and this thread: It’s a subjective choice that you think is slightly better than removing a barrier/major annoyance for an entire group of people that may want or need to interact with your code. It’s closing the door on possibility for a minor personal preference.

      • @[email protected]
        link
        fedilink
        21 year ago

        That reminds me of those times when back on reddit some dev showed up to present their new GUI library. Bragging about how they were better than Qt devs etc. (even though they didn’t implement the hard parts, like working text fields or tables)

        After some time a bunch of people had enough and started bullying those guys into submission about accessibility. After some time, every of those toolkits had support or at least plans for supporting screenreaders. Eventually, AccessKit became a thing.

        Good times.

      • @[email protected]
        link
        fedilink
        11 year ago

        Arguing that it’s invincible to convince people at large to adopt tabs over spaces with good arguments is a ridiculous statement

        I do actually think that it is very hard to convince basically every programmer of something, no matter how good arguments you have.

        Also, without knowing much about the issue, it sounds a bit like the tooling for people using braille displays isn’t very good and fixing that is maybe also worth advocating for, perhaps it’s even a strategy for advocacy that is more effective?

    • @pexavc
      link
      41 year ago

      Yeah. It is depressing.

      I’ve always wanted an accessibility feature that uses haptic feedback to mimic braille patterns for reading purposes too.

      In general a lot of creative stuff can be done if we focused on it even a tiny bit more.

  • @shotgun_crab
    link
    English
    35
    edit-2
    1 year ago

    Code formatter and run auto format

    • @_stranger_
      link
      5
      edit-2
      1 year ago

      Holy wars are fun, but this is the answer.

      At least this way the holy war takes place in commits to change the formatting file.

      Unless go, in which case the holy war is now everyone who hates go format rewriting the code in a different language.

  • corytheboyd
    link
    fedilink
    331 year ago

    I wish every language had a gofmt, this is such a non-debate (tabs are indentation, spaces are alignment)

      • Tempy
        link
        fedilink
        61 year ago

        And over gofmt, rustfmt lets you set settings for the project. Keeps the code looking how I want, and contributers don’t have to care.

        • @[email protected]
          link
          fedilink
          11 year ago

          The absence of settings in gofmt is a feature. The kind of basic formatting it handles is not worth having opinions about.

  • @[email protected]
    link
    fedilink
    311 year ago

    Neither tabs or spaces are good. The correct way is to leave no whitespace in the code at all. It’s unnecessary and adds to processing time.

    Everyone should aim for 1LOC per commit

    • Dark Arc
      link
      fedilink
      English
      111 year ago

      My program, written in the whitespace language, ruined.

      CURSE YOU PERRY THE PLATYPUS!

      • @MajorHavoc
        link
        21 year ago

        Now next time I read anything about why any Python libraries are named what they are named, I’m going to hear Dr Doofenschmirtz voice. Thank you for that.

  • z3bra
    link
    fedilink
    301 year ago

    Tabs for indent, spaces for alignment. This is the way, I can’t believe people are still fighting that ?

    • @[email protected]
      link
      fedilink
      28
      edit-2
      1 year ago

      Anything for indent (barely matters, as long as the editor forces it to stay consistent), and fuck alignment, just put things on a new line.

      • z3bra
        link
        fedilink
        16
        edit-2
        1 year ago
        struct Ident arr = [
        {
        .id
        = 0,
        .name
        = "Bob",
        .pubkey
        = "",
        .privkey
        = ""
        },
        {
        .id
        = 1,
        .name
        = "Alice",
        .pubkey
        = "",
        .privkey
        = ""
        }
        ];
        
        • @[email protected]
          link
          fedilink
          16
          edit-2
          1 year ago

          Not like that, lol

          Just saying, instead of this monstrosity

          CreateOrderRequest(user,
                             productDetails,
                             pricingCalculator,
                             order => order.internalNumber)
          

          Just use

          CreateOrderRequest(
              user,
              ...
          

          Putting the first argument on a separate line.

          Same if you have an if using a bunch of and (one condition per line, first one on a new line instead of same line as the if) and similar situations.

          • @[email protected]
            link
            fedilink
            81 year ago

            People seem to have a real issue with using new lines and I’ve never quite understod why.

            It feels like a lot of those people are using notepad like applications instead of coding focused ones with collapsible regions etc.

          • z3bra
            link
            fedilink
            6
            edit-2
            1 year ago

            When I talk about alignment it’s not about function arguments, but values, “=” signs and such. You simply cannot use tabs for that because alignment must be fixed and indentation independent:

            CreateOrderRequest(
                user,
                productDetails     => order.detail,
                pricingCalculator  => DEFAULT_CALCULATOR,
                order              => order.internalNumber)
            
            • @[email protected]
              link
              fedilink
              10
              edit-2
              1 year ago

              I normally avoid that too, I find it hurts readability more than helps, plus a proper IDE will separate it with color anyway.

              But yeah, the newline comment doesn’t apply to this.

              • z3bra
                link
                fedilink
                11 year ago

                To each their own indeed. But my rule of thumb is: only use tabs when there’s no other character before it (aka, start of line).

                • Nate Cox
                  link
                  fedilink
                  English
                  11 year ago

                  The emacs wiki agrees and has the correct take on this: https://www.emacswiki.org/emacs/SmartTabs

                  It seems like this basic guideline, tabs to indent and spaces to align, solves the problem for everyone. It doesn’t matter what your tab width is, it’ll look “right” regardless.

            • PHLAK
              link
              English
              61 year ago

              This kind of “manual” alignment should be avoided for many reasons including the fact that adding/removing/changing of one parameter here may force you to modify multiple lines which on it’s own is annoying but this will also show up in the diff during review making it harder to grep what was actually changed.

              • z3bra
                link
                fedilink
                21 year ago

                I personally favor code readability over patch readability. But I reckon this is a matter of preference so I can understand how you might not like that.

            • @[email protected]
              link
              fedilink
              41 year ago

              Yeah I agree I don’t find alignment very useful. It’s more work for dubious benefit, and god forbid you change one of the lines.

        • @hansl
          link
          61 year ago

          The way god indented.

      • @[email protected]
        link
        fedilink
        01 year ago

        seconded on not aligning things. its the whole source of the problem in the first place and doesnt even serve a purpose

        • @MajorHavoc
          link
          11 year ago

          It does help with reducing thrashing between edits in git diffs. Or rather, opinionated autoformatters do, which is the only reason I bother with alignment.

    • @[email protected]
      link
      fedilink
      81 year ago

      I used to think this way, at least when writing C++. But it’s objectively harder to do and convince other people to follow, especially if they can’t be bothered to change their environment to display tabs and spaces differently. It’s a losing battle so now I just do spaces when working with other people

      • @KIM_JONG
        link
        01 year ago

        Always do spaces, because you can never trust how someone else has their tab configured.

        How is this even a debate anymore. I thought we all agreed on this years ago.

        • Pyro
          link
          English
          31 year ago

          you can never trust how someone else has their tab configured

          Why on earth would I care how someone else has their editor configured? It’s none of my business, and none of yours either.

          • @[email protected]
            link
            fedilink
            2
            edit-2
            1 year ago

            Because other people are fucking morons and their editor doesn’t have visible whitespace enabled - or it does but they don’t give a shit.

            Therefore these fucking morons have anywhere between 2 and 8 spaces-per-tab configured and will happily mash the tab key however many times is convenient for them to align their code or comments because they don’t understand shit about fuck when it comes to alignement (or they don’t care). Now I open their file and everything is predictably misaligned. Spaces and tabs are mixed from one line to the next, and in particularly egregious cases no tab width I can locally set on the file will make it readable because multiple different morons used different tab widths to align with tabs - sometimes within the same goddamn function or comment.

            Have you ever tried to read an important technical diagram in ASCII art aligned with tabs by different people with different IDE settings? Because I have. Emphasis on tried.

            • Pyro
              link
              English
              21 year ago

              Spaces and tabs are mixed from one line to the next

              This is a solved problem: Enforce linting before committing using something like Git Hooks / Husky.

              Have you ever tried to read an important technical diagram in ASCII art aligned with tabs by different people with different IDE settings?

              No, because we live in the present and use proper tools for diagrams. SVG diagrams tend to be common nowadays. I’m aware you can’t read them raw, but realistically the intersection between people who need to read important technical diagrams and people who don’t have access to a web browser is vanishingly small (dare I say nonexistent?)

              • @[email protected]
                link
                fedilink
                11 year ago

                Tell me you develop with modern languages without telling me you develop with modern languages.

                Try linting perl, or bash.

                Like yeah if you work on a modern JS/Python/C# project, whatever, whitespace is going to be autoformatted, so the tabs vs spaces debate does not matter AT ALL.

                • Pyro
                  link
                  English
                  21 year ago

                  Tell me you develop with modern languages without telling me you develop with modern languages.

                  You say this like it’s a bad thing?

                  Try linting perl, or bash.

                  If you’re already writing Perl/Bash scripts then it would probably not take you long to write a git hook to check the beginning of each line of source to check if there’s a space or a tab character and preventing the commit if the wrong one is found. Crude and far from perfect, but still better than nothing.

                  if you work on a modern JS/Python/C# project, whatever, whitespace is going to be autoformatted, so the tabs vs spaces debate does not matter AT ALL.

                  It does though. If you read the original article then you’d know that the advantage of tabs is that everyone can choose exactly how deep their tabstops are, which is an objective benefit over spaces.

    • AnyOldName3
      link
      61 year ago

      I’ve yet to find tooling that supports this. Clang format has a setting that looks like it does it, but actually does something else. If I have to press the spacebar a bunch of times each time I add an argument to a function, that’s a pain, and it’s a bigger pain to convince the people I’m working with that that pain’s less bad than using spaces everywhere and having the IDE deal with it.

      Until the people making editors and auto formatters acknowledge that the obvious most sensible whitespace style is even a thing, I’m forced to do something else and be really grumpy about it.

      • z3bra
        link
        fedilink
        11 year ago

        I understand your point of view. Personally I either copy the previous line and replace the arguments there, or insert X number of space using the repetition feature of my editor. It also has a feature that will align multiple cursors together with the “farthest” one using space, which is a killer feature for me! (See this presentation video @1:40).

    • @[email protected]
      link
      fedilink
      41 year ago

      It’s hard to do this consistently (especially in a team) because people might (and statistically in a large enough project, will) use the tab key for alignment since it’s faster than pressing space, or just be confused about what whitespace is tabs and what is space. Just using space everywhere is idiot proof and requires no work to micromanage. The only way to use tabs is to not align at all.

      • @jsnfwlr
        link
        31 year ago

        And this is why language servers and formatters are so critical.

      • z3bra
        link
        fedilink
        11 year ago

        I agree that it’s hard, but not impossible. This usually boils down to how Nazi people are when merging code. In a corporate environment, nobody gives a damn so yeah you gotta use whatever you want because there are already different indentation systems within the same file anyway :)

        But hey, you gotta live by the changes you want to see happen, so I personally put a lot of effort in formatting my code regardless.

  • stevecrox
    link
    fedilink
    20
    edit-2
    1 year ago

    Years ago there was no way to share IDE settings between developers.

    You ended up with some developers choosing a tab width of 2 spaces, some choosing 4 spaces and as there was no linting enforcement some people using 2-4 spaces depending on their IDE settings.

    This resulted in an unreadable mess as stuff was idented to all sorts of random levels.

    It doesn’t matter if you use tabs or spaces as long as only one type is consistently used within a project.

    Spaces tends to win because inevitably there are times you need to use spaces and so its difficult to ensure a project only uses tabs for identation.

    IDE’s support converting tabs into spaces based on tab width and code formatting will ensure correct indentation. You can now have centralised IDE settings so everyone gets the same setup.

    Honestly 99% of people don’t care about formatting (they only care when consistency isn’t enforced and code is hard to read), there is always one person who wants a 60 charracter line width or only tabs or double new lined parathensis. Who then sucks up huge amounts of the team time arguing their thing is a must while they code in emacs, unlike the rest of the team using an actual ide.

    • @[email protected]
      link
      fedilink
      English
      01 year ago

      inevitably there are times you need to use spaces

      When? You indent with tabs then add any spaces you want for precise alignment. When would you need to use spaces to indent?

      • stevecrox
        link
        fedilink
        5
        edit-2
        1 year ago

        Do not mix tabs and spaces.

        Its impossible to automate checking that tabs were only used for indentation and spacing for precise alignment. So you then take on a burden of manually checking

        You end up with the issue where someone didn’t realise and space idented or anouther person used tabs for precise alignment and people forget to check the whitespace characters in review and it ends up going inconsistent and becoming a huge pile of technical debt to fix.

        Use only one, you can automate enforcement and ensure the code renders consistency.

  • darq
    link
    fedilink
    191 year ago

    I’ve always wondered why some people tout “forcing a consistent appearance across environments” as a pro for spaces. That’s a bad thing.

    To be honest I’m surprised code format converters aren’t ubiquitous. Let the repo have it’s master format, enforced on commit. Then converters translate into each developer’s preferred standard dialect on checkout and back again on commit.

    • exscape
      link
      fedilink
      81 year ago

      The consistent appearance thing is probably more about how mixing tabs (for indentation) and spaces (for alignment, eg in multi-line function definitions of calls) looks like complete crap if you change the tab width.

      • @[email protected]
        link
        fedilink
        71 year ago

        I think you have it backwards. If you use tabs for indentation and spaces for alignment it works great for any tab size.

        It is when you use a tab just as a compressed representation of 8 spaces and use them for alignment as well that it goes to shit. (because you have made the sin of tab == 8 spaces instead of the correct tab = 1 indent level)

        • exscape
          link
          fedilink
          01 year ago

          How does that work, and with which editor settings? If you simply set the tab width (tabstop) in vim, things go south.

          Say you have a function definition one indent level in, then 22 characters of text. You more want to align the next line to that. How does that work in practice with tabs?

          The obvious way with tabs and ts=4 would be 6 tabs and two spaces(one tab for the initial indent, the rest to match 22 characters). But then someone with ts=2 comes along and barely gets half way there, or someone with ts=8 who overshoots by a lot.

          • @[email protected]
            link
            fedilink
            English
            51 year ago

            That’s not how you should mix tabs and spaces for alignment. You use the same number of tabs as the previous line, and then fill the remaining width with spaces. That way, when you change tab width, the alignment spaces will always start in the same column as the line they’re aligning to, regardless of the tab width.

            • exscape
              link
              fedilink
              41 year ago

              Do most editors do that by default? If so, that’s great – if not, it’s just a downside for tabs, if you need to hit enter, backspace out the automatic indents and then press space 30 times rather than just hit enter and have it aligned automatically.

              vim seems to auto-insert tabs when you hit enter mid-function definition, at least with standard settings.

              • @[email protected]
                link
                fedilink
                English
                11 year ago

                That seems like a problem with Vim, then… Typically I don’t align at all, so I’m not familiar with editor behavior for alignment; I prefer to just indent one level deeper.

          • @[email protected]
            link
            fedilink
            31 year ago

            Setting tabstop and shiftwidth differently is basically legacy braindead behaviour. It is going back to the logic of tab is just a way to compress spaces. If you are doing that then you have all of the problems of both tabs and spaces.

            As for alignment the easy answer is don’t use tabs for alignment. Use tabs for indentation, if you want to align something use spaces for the alignment past the indentation. Lemmy seems to be breaking code snippets right now but I have a really old blog post about this.

            https://kevincox.ca/2014/06/26/responsive-tabs/

            The post is a little out of date when referencing the style of my blog but the C example shows alignment. If you can resize the browser you can see that the indention changes from 4 to 2 as the screen gets narrower without breaking the alignment.

      • JackbyDev
        link
        fedilink
        English
        6
        edit-2
        1 year ago

        Using only tabs for indentation and only spaces for alignment will never result in crap alignment when adjusting tabstops because the alignment does not use tabs.

        This is using both tabs and spaces for alignment.

        --->func foo(int i,
        --->--->     int j);
        

        Observe what adjusting the tabs does,

        ->func foo(int i,
        ->->     int j);
        

        This uses only spaces for alignment,

        --->func foo(int i,
        --->         int j);
        

        When converted the alignment is maintained because the tabstops aren’t used for alignment, only for indentation.

        ->func foo(int i,
        ->         int j);
        
    • @_stranger_
      link
      81 year ago

      Soft tabs are superior. press tab-> get 4 spaces.

        • ggppjj
          link
          21 year ago

          I use a product that has a homegrown scripting language that enforces two space tabs and will crash with anything else.

          • @[email protected]
            link
            fedilink
            Deutsch
            11 year ago

            My main issue is that they keep changing format all the time and making merge requests unnecessarily difficult. Wanna use two? I hate it but fine. But let’s agree on this and change our formatter all at once.

  • @[email protected]
    link
    fedilink
    131 year ago

    Yesterday, I shared some spicy takes. A few were particularly controversial—most notably, that I correct Gif the correct way (with a soft G)

    And I stopped reading there.

  • @[email protected]
    link
    fedilink
    English
    131 year ago

    I consider tabs for indentation a failed concept.

    The idea is good, but it evidently failed. Most guidelines and newer Tools recommend or require or use spaces for indent. They have their reasons too.

    The prevalence of spaces makes it hard to make a contrary argument for tabs. By now, I don’t think it’s worth even if it had reasonable advantages.

    Editors/IDEs that parse syntax can adjust space indent too. A mixture for indent and alignment is not obvious for everyone (I always display whitespace in my editors and am deliberate and consistent, but many people and editor defaults won’t be). Some defaults of four or eight space-width tab display is atrociously wasteful and inaccessible.

    Spaces are a good enough baseline. It works well enough. And most importantly it works consistently. That’s why it won in prevalence and use.

    • xep
      link
      fedilink
      51 year ago

      If I could only get everyone who works on the thing I work on to use a whitespace visualizer, it would be enough. We can fight about tabs or spaces after we get rid of all the unnecessary trailing ones.

      • @Olap
        link
        51 year ago

        You’ve a .editorconfig in your repo right? Right?

      • @[email protected]
        link
        fedilink
        English
        21 year ago

        I created a tool for removing trailing whitespace across the whole project. After cleanup now it’s at least only a matter of pointing it out in reviews and occasionally fixing landed sources.

      • @[email protected]
        link
        fedilink
        English
        3
        edit-2
        1 year ago

        Do you have actual experience with it?

        Some time ago I read a comment from someone with impaired eyesight who used an editor that would adjust space indent just fine.

        Accessibility is a thing I always consider.

          • @[email protected]
            link
            fedilink
            English
            1
            edit-2
            1 year ago

            I would have preferred tabs to win for this reason.

            Unfortunately, as you pointed out, “good enough” can be excluding, non-inclusive. Overall it works well enough for enough people / none with impairment stumbled over it yet, did not voice or were not heard.

            the majority of healthy people has no problem marginalizing minorities with disabilities

            I wouldn’t attribute malice like this though. Most people just don’t care or are not mindful and thorough.

  • @Duralf
    link
    101 year ago

    This is a holy war that I will gladly fight again and again! I can’t believe that soft tabs are more popular, especially in python!

        • @[email protected]
          link
          fedilink
          01 year ago

          Actually I think you can technically mix. They have a “conversion factor”. But don’t, because then the code will look like crap on any other tab size (defeating the point of using tabs in the first place)

          I think it would be better that each line needs to start with the exact same bytes to be considered within the same indent level. But I don’t think that is the decision Guido made.

    • @_stranger_
      link
      11 year ago

      That is because they are superior.

      spatium vult.

  • @[email protected]
    link
    fedilink
    91 year ago

    The argument for having tabs adjust depending on your ide sounds better than it is in practice. Someone formatting code to look nice with width 4 will look horrendous for someone who uses width 8.

    Spaces makes it uniform and captures the exact style the original dev intended

    • @[email protected]
      link
      fedilink
      111 year ago

      If you have your tab width set on 8, that is on you. You will also set your IDE to insert 8 spaces when you press TAB and I will cry when I have to give you a code review.

      When I indent my code, I am indicating that I am in a nested block. I don’t care if, on your screen, that indent is 2, 3, or 4 characters.

      • @Acters
        link
        21 year ago

        Anarchist: tab with set to 1

        • @[email protected]
          link
          fedilink
          21 year ago

          That’s fine, when I view it I will get my preferred tab width. This situation is only anarchist with spaces, with tabs they are just a masochist.

  • asudox
    link
    81 year ago

    Tabs take less space (space as in space in storage, like free as in freedom) tbh.

    • @AnUnusualRelic
      link
      81 year ago

      My disk is almost full! Better switch to tabs for indentation!

      • asudox
        link
        11 year ago

        Happened to me quite a few times, relatable situation.

  • mckean
    link
    fedilink
    81 year ago

    I think calling one way better than the other is flawed. The reason the title is saying that tabs are objectively better is because they are used in addition to where spaces are used elsewhere. You could make the same argument in favor spaces due to keeping things simpler.

    The argument of having variable indent size for tabs so viewers can decide how big they are is imho legitimate but also not the goal as it’s addressing something that teams generally agree on. There is max characters per line, brace placement, general code style and rules. Yes we can eject the indentation from the rules that are agreed on but once again simplicity over complexity has an equal say.

    In the end it doesn’t matter that much, a good programmer will be able to work in either setting, the Editor will do most of the work anyways.

    With all that said, spaces all the way!