0

Tabs vs Spaces

Comments
  • 6
    Bikesheds?
  • 1
    @PeterDCarter I think it's look better in red
  • 8
    Really?

    Tabs converted to spaces,
    There's no alternative!
  • 4
    Whatever your project already uses
  • 4
    Tabs. You can make them appear as wide as you want without making changes to the code (like using spaces forces you to). You like 2 spaces worth of indent while your colleague likes 4? No problem, just don't include the tab width setting in the repo. The only way tabs fall short to spaces is when aligning stuff, but I've rarely needed that.
  • 3
    Linux vs Windows line endings... *distant sounds of things collapsing*
  • 4
    Tabs make editor controls inconsistent dogshit.

    Will the cursor move 1 character or 4? Who knows, it's a tab so fuck you.

    And don't bring up that stupid "it looks right for everyone" argument, it would be easy for editors to automatically detect indentation width of a source file - tabs or not - and display it according to the user's settings.

    So in that sense spaces are superior - they always stay consistent when vertically aligning code, and the editor could automatically handle everything else. And you wouldn't have to deal with an invisible character that can theoretically have any length, because what text rendering/editing in the era of Unicode really needed was more pointless inconsistencies.
  • 3
    [laughs in writing minified code]
  • 2
    Neither, I only write uglified code
  • 3
    2 spaces and 1 tab
  • 0
    @netikras I use a fuzzing algorithm seeded with an encrypted version of AM band radio chatter to determine the number of spaces on any single line. It's important to maximise entropy
  • 0
    @PeterDCarter the great thing about this is if you look closely enough at the result you start to piece together a strange alien language...
  • 2
    I don't give a shit, as longs as it's consistent. i use whatever is preset in my editor of choice.
  • 1
    ShiftTab, anyone?? 😂
  • 2
    tabs for sure.
    visually, anyone can set them to any width they prefer.

    semantically, it's literally a nesting/indentation character, as opposed to space which is a, let's call it, token separation character.

    tabs make sense on all levels. spaces are stupid and make no sense on all levels.

    oh, and ergonomy. one tap of tab key versus arbitrary number of bashes on spacebar. guess which is more ergonomic.

    using spaces for indentation is literally the direct equivalent of using spaces to horizontally center title text in word processors.
  • 2
    @Midnight-shcode "one tap of tab key versus arbitrary number of bashes on spacebar"

    Most people avoid Notepad, but no kinkshaming.
  • 0
    Aha. Sure. Yup. Whatever.
  • 0
    @Midnight-shcode lmao did you seriously just use an argument 1x tabkey vs bashing spacebar 4x
  • 1
    @deadlyRants Yeah because I love having to consistently tap right 4 times, very ergonomic
  • 3
    There are more important dichotomies.

    Like monolith vs micro-service.
  • 1
    Tell that to python developers
  • 0
    @deadlyRants i don't trust people who don't even know the proper usage of tabs and spaces to be aware of any other text editor than notepad existing ;)
  • 0
    @myss of course i did. as the last, least important, smallest point, but still important enough to solve the debate by itself.
  • 1
    @bittersweet that's just a question of "constipation or diarrhea?"

    two extremes, both equally bad in different ways for different reasons.

    the good third option is "proper architecture derived from, and thus suited for, the problem at hand, not religiously sticking to some buzzword simplification because buzzword"
  • 2
    @Midnight-shcode

    And thus a more interesting topic than tabs/spaces.

    Tabs/spaces is like "Fucking pick one. Probably the common one for the language. Who cares"

    Monolith vs microservice is indeed a scale, with super interesting questions like "When do we break up our monolith?", "How do we transition without getting stuck?", "How do we identify context borders?", "If we take a hybrid approach, how do we determine the architectural rules we use?"

    So, it's an example of a more interesting discussion.

    Just like "Does a type system require generics to be considered good?" or "What are the best mitigations for the object-relational impedance mismatch problem?"

    Tabs/spaces... Bleh. Not worth the energy. Now that you mention it, I would rather have a discussion about constipation vs diarrhea, than tabs vs spaces.
  • 1
    @12bitfloat Out of genuine curiosity, what ass-backwards editor do you use that can't insert space-based indentation with the tab key?

    Where do people even get the idea that space-based indentation needs the spacebar at all?
  • 0
    @deadlyRants No that's okay. What really gets me is moving around with the arrow keys. Ain't got time to touch the mouse
  • 1
    @12bitfloat Ctrl+arrow should get you right where you want to go, alternatively there's a Home button on most keyboards which (at least in VSCode) first moves you before the first non-whitespace, then jumps between that and the very beginning of the line on repeated press.

    Edit: unless where you want to go is in the middle of the indentation, between two whitespace characters, but I really can't imagine why you'd want to do that.
  • 0
    @lbfalvy I use end, home + arrow keys a lot. Trust me, having spaces is just a damn nuicanse. One some editors home switches between coloumn 0 and the first character of the line, I'm a major user of that, but I still move around with arrow keys a lot. I have not once had a good experience with space-based indentation yet
  • 0
    @12bitfloat I also hardly ever use the pointer since I program on a laptop, I can't recall the last time I had to move the cursor across indentation.
  • 0
    @lbfalvy ??? How to you move across your codebase??
  • 0
    @12bitfloat up, down, long left (Ctrl-left), long right (Ctrl-right), home, end, left & right for fine positioning.
    Because long steps always skip all whitespace, I never even have to think about what kind of whitespace it is.
  • 0
    @kamen spaces users are not open to logic - don‘t bother trying to explain it.
    Most of then don‘t even know there are linters and auto formatters. Instead they prefer go manually align their content - which they need spaces for.
    That‘s the only reason for spaces. And imho it‘s a dumb one. I want consistent formatting throughout all code files. Have fun doing this manually.
    I would never hire such a dev, because they are either sloppy and don‘t care for consistency, or they waste precious development time for formatting code manually.
    Both is unacceptable.
  • 0
    @PeterDCarter I never had any issues like that in 20y of experience.
    As long as no one uses notepad, you should be fine.
    And if someone used notepad, I would seriously question his dev abilities.
  • 0
    @deadlyRants no it‘s not easy for an editor to detect what the one line with 3 spaces should mean when all other lines are intended with a multiple of 2 two, let alone how to convert it back to spaces.
    1 tab is always what you want it to be.
    How should it not be consistent? It‘s always consistent.
    I‘ve seen a lot of code bases intended with spaces, and all of them with no exception, were really inconsistent.
  • 0
    @mojo2012

    Eh, I'm working on a 4-space indented PHP codebase, and phpstan will disallow you to commit 2 or 3-space indentation, or indent unnecessarily, or not indent, or...

    Also, at least with Jetbrains IDEs, there's no ergonomical difference. It detects which indentation is used in the project, and will create a consistent experience.
  • 0
    @mojo2012 When in doubt show an error, whatever. Because no, inconsistencies are not as common as you make it out to be - in Python that would be a syntax error and I've never encountered it. It's almost impossible to unintentionally mess up space-based indenting. The editor can treat it as if it were tabs, but without the cursor going crazy. Best of both worlds.
  • 0
    @mojo2012 "Most of then don‘t even know there are linters and auto formatters. Instead they prefer go manually align their content - which they need spaces for."

    Auto-formatters are garbage for readability, they aren't designed with humans in mind. In larger teams you have to use them for practical reasons, but that doesn't make the outcome less miserable.

    "they waste precious development time for formatting code manually."

    No, they don't. They use plugins to make it a matter of two keypresses. It's not AI rocket science.
  • 0
    @mojo2012 issue like what? Windows vs Linux line endings? That was tangential purely based on "vs" association. Someone using fuzzing algorithms to generate whitespace on a per line basis?

    I didn't actually comment any argument one way or another because I don't care a fig as long as it's consistent.
  • 0
    This rant has 0 likes but over 40 comments… Is the algorithm still ranking rants based on just likes?
  • 0
    @deadlyRants i‘ve almost never seen unreadable garbage, from java to ts, css or html.
    In contrary actually: everything is always as expected and consistent.
    If you have code that an sutoformstter can‘t handle anymore, I argue the code is just shit!
    I just refactored code from a colleague, 3 or more nested if‘s, that could be combined, a myriad of parameters, huge type names (100 chars and more). The problem lies elsewhere ….
Add Comment