1. 21

  2. 7

    Bah, only C programmers seem to get it right. All other langs are doomed already!

    1. 10

      While C is definitely on the side of Good, Go is really showing the way here.

      1. 1

        gofmts style is no one’s favorite, but gofmt is everyones favorite.

    2. 4

      When the AI revolution finally happens, the tabbers will be the first to go.

      1. 1

        Then the spacers come next. The mixed users will be the last, having to endure the most amount of torture.

      2. 3

        Obligatory historical link: https://www.jwz.org/doc/tabs-vs-spaces.html

        1. 2

          The way I’ve always looked at it is to just pick a style guide and stick to it. I write a lot of PHP and so I stick with the PSR-2 style guide which has me use spaces over tabs for indentation, at four characters long. I’m pretty sure the Linux kernel style guides say you need to use eight character tabs, and I like to write my C in that same way.

          I don’t see a problem with using either, especially when there are established style guides out there for almost every language.

          1. 2

            I frankly don’t get why people insist on spaces. Please, someone, enlighten me. Please. I wanna understand why a single resizeable character is inferior to a small pile of unresizeable ones.

            1. 4
              1. tabs (and all other invisible characters, see dos2unix) have consistently proven to be difficult-to-understand and error-prone among computer users
              2. resizing is easy in an environment you’re familiar with, but in practice people often operate in environments that they are unfamiliar with, so the lowest common denominator (i.e. what I can do without thinking in Notepad.exe) wins.
              1. 5

                The biggest problem is that they get mixed inadvertently. Go has shown that a program can actually fix it. As a result, my editor reads tabs, I often type spaces, and gofmt makes it standard tabs on save. This is legitimately the best feature of the Go tool chain.

                Years ago when I programmed in Python, there would always be that one committer who would insist on tabs, or use 3 spaces instead of 4 in some places, and all hell would break loose in the commit history–annoying, but not the end of the world. The shameful person, btw, didn’t do the cleanup, cause they didn’t give a shit.

                In summary, this is the least of our problems and can be automated incredibly effectively if it means enough to you, but if not, who cares?

                1. 1

                  Nowadays, tooling has improved in Python, too. You can also use tools like autopep8 or yapf (https://github.com/google/yapf) to autoformat Python code (yes, that is a thing ;) )

                  1. 1

                    That’s pretty great! Thanks for the link!

                2. 1

                  The problem is the assumption that allowing it to be resized is even desirable in the first place. If you are working on a specific codebase, you need to stick with the style that the codebase dictates. Imagine if people thought it was a good idea to allow “flexible brace styles” to let you use your preference. Why must indentation be different?

                  If you want the code to be displayed differently according to your preference, it should be implemented as a rendering-time hack (for instance, showing “lambda” as “λ”, etc) rather than changing the actual bytes on disk. Rendering 4 spaces on disk as 8 spaces on screen is a trivial config change in any decent editor.

                  1. 1

                    Some languages are whitespace sensitive and a tab doesn’t always represent the same number of characters so making everything done with spaces is the simple, easy way out when dealing with vertical alignment. Gofmt does vertical alignment pretty nicely and it works well across different editors and even with doublewidth characters involved etc but most developers don’t like using a formatting tool outside of what its editor does on its own and most languages don’t even have an agreed upon format so there lacks formatters for those languages, because adoption would stumble.

                    1. 1

                      Also, if you follow a convention like “maximum line-length 80 chars”, …

                      1. 1

                        In order to allow tab characters in your code, you have to disallow certain coding styles to prevent misalignment when tab sizes change. It’s much easier to simply disallow all tab characters, especially as the team size increases.

                      2. 1

                        It’s not about tabs or spaces, it’s about using them correctly.

                        Only tabs for indentation (mostly following module/code scope), and only spaces for alignment - that way code looks good regardless of tab size settings.

                        for (int i = 0; i < j; i++) {
                            printf("very long text ending with %d\/%dn",
                        ^tab - indentation
                                   i, j);
                        ^tab^spaces - indentation + alignment

                        But, sadly, not many editors can be set to easily and properly follow these rules. Alignment is very often performed using tabs, and then tab size other than code author’s leads to awful formatting, which I suspect is the main reason behind let’s-use-spaces-only reasoning.

                        1. 1

                          The mixing of tabs and spaces in, eg, BSD style(9) always grates a little. For example, from the FreeBSD variant:

                          Indentation is an 8 character tab. Second level indents are four spaces. If you have to wrap a long statement, put the operator at the end of the line.

                          I can understand why it’s there, but…

                          1. -4

                            I don’t get it. C uses tabs, because on 80x25 it makes you write better code. Everyone else encourages a little deeper nesting, ergo shorter tabs, ergo spaces.

                            The girl in the video is n00b though. If she uses vim, then set sw=4 ts=4 et and stop getting in the guys nerves.