23

Hi fellow code indenters,

I am a tab indenter myself because each dev on the same project can decide how much the indentation is. Some prefer 4, some 2, some prefer both depending on language.

Now I already asked a few space indenters here why spaces. Because I never heard a good argument for using spaces instead of tabs. Each time I asked I didn't get an answer.

So this time once again: why would you use spaces over tabs for indentation?
I want to make a good decision and for that I need arguments for both.

Comments
  • 14
    Hi, I also use tabs but let's maybe not discuss religious topics XD
  • 2
    @dontPanic im open to switch religion if I think I can benefit from it more.
  • 5
  • 3
    I heard tabs destroy the GitHub layout... But probably they fixed it already (I didn't test it). Other than that, I use tabs which are automatically converted to spaces in all IDEs I use, so noone can complain.
  • 9
    My reasoning for spaces is because you can't always configure the size of a tab, and also inserting tabs doesn't always work in terminal based editors.

    BUT WITH THAT BEING SAID... who cares? Honestly, as long as you're consistent, whatever you choose is cool with me!
  • 4
    @arcadesdude but why? Like all of you space indenters you dont tell why...

    Im not asking what is better. Im fucking asking why.
  • 1
    @VirtualProtect okay, that is something I can work with, terminals might have problems with tabs indeed.

    But what editor doesnt let you change tabsize?
  • 3
    @Codex404 Well, mostly because I don't care. My code runs well both with spaces and tabs. And that's what counts. I never checked my IDE settings just to turn that of, because, as mentioned before, I don't care.
  • 2
    @Codex404 terrible example.. but notepad on windows. Also not every terminal based editor has the option to change tab size OR it is a terrible pain to change them
  • 2
    @VirtualProtect i cant imagine people building big projects with terminal based editors. But it is a valid reason indeed.
  • 2
    @Codex404 totally agree with you, I can't imagine that either, but it's more-so for that one-off time you're already working in the terminal, and you need to edit a file quickly! That's all I can think of. Anyways, with that being said, I don't prefer spaces over tabs. I just tend to use spaces, but I don't have any logical reason for doing so 🤷🏻‍♂️
  • 5
    Cause we live in a crazy world. When I ask this question to myself, remember the people who likes pizza with pineapple on it, and I realize that could be worst.
  • 3
    @Codex404 @VirtualProtect pretty much every *nix server has 1 or more of vim, emacs and nano. I know you can change it easily in vim, but I'm not positive about the others (though I expect you can) so I don't think terminal is really that *valid* of a reason.

    The ONLY reason I've ever come up with as a valid reason is for enforcing line length constraints. If you use a variable size charcter(tab) you can't reliably predict the line size to be within a character limit (example being 80 characters for diff'ing 2 files side by side on a smaller monitor (or someone with vision problems)

    Outside of this argument I've yet to hear a valid argument for using spaces for indentation.
  • 1
    @Codex404 simple. Control. You can exactly line stuff up with soft tabs and even set how many spaces they act as. So you get the standard spacing and consistency of tabs along with the extra control needed to align everything perfectly. I honestly can't see someone using only (hard) tabs for indentation when you could use soft tabs for fine grain control.
  • 1
    @jAsE You can do that easily using any IDE I know :)
  • 0
    @brettmoan saying a comment is spam is just spam and by your logic also doesn't provide any reasons for the OP.

    Why would you want to use hard tabs over soft tabs anyway? Literally nothing hard tabs can do that soft tabs can't with a good ide/editor.
  • 2
    @jAsE what pisses me off is coding with someone who uses spaces especially at a large size (3 or 4 or even 5). I use hard tabs, size 2. If they want to see it at 4, set their tab size to 4, but if you use fucking soft tabs at size 4, there is 4 literal spaces for indentation and tons of wasted space when I'm working in the code.

    Soft tabs are inflexible, because they replace a variable width character with a set number of fixed width characters.
  • 2
    @arcadesdude soft tabs are literal spaces, if you open a file with literal spaces it doesn't magically "conform" to your indentation preference on size. Soft tabs are forcing your preference for indentation on others.

    /s Its basically Fascisism /s
  • 4
    Oh god this is turning into a tabs v spaces bloodbath. I think OP was just looking for reasons why people use space lmao
  • 0
    @brettmoan doesn't force anything. You actually get the option to use what you want and if your editor/ide is smart then it will allow soft tabs characters to be changed as well not magically not changed nonetheless. So democracy rather than fascism. Now, why would you want to use hard tabs when you can use nice soft tabs which can do everything hard tabs can do???
  • 0
    @arcadesdude so your only forcing my choice in editor?

    @jeffalyanak when you say "converting spaces to soft tabs" I assume you mean visually, and not an actual change of the ascii values underneath correct? Cause I know of no "soft tab" character. If this is the case, is your editor converting the look of for example 4 physical spaces for on indentation to the size of your soft tab size? For example when a contributor prefers size 2 indentation your saying your editor is effectively hiding 2 spaces at every indentation level?
  • -1
    @VirtualProtect well holy wars are the wars that only end in the annihilation of the "heritics". While tabsVspaces is a lighthearted debate, its an disheartening parallel to real religious holy wars.

    Full opinion: in your own project IDGAF what indentation you use, if it's my project tabs are enforced at commit, just as major projects spaces are enforced at commit. (like anything into python forces full pep8 4 spaces for indentation and everything else is heresy).
  • 2
    @Codex404

    yeeeep.... Who saw the war coming...?!

    🌋🌋🌋😈😈😈
  • 3
    @RickDiculous179 i tried formulating it so that there wouldnt be a war. And I do think it isnt that bad yet.
  • 0
    @Codex404 I agree this is pretty civil (for the most part). But an eventual flame war will be inevitable. There's a reason for this, but describing it would actually incite the flame war even more.
  • 1
    @jeffalyanak huh. I've never seen that particularly (where the physical file contains spaces but the editor shows you a "soft tab object" of different size than the actual underlying spaces.

    But this would be very editor dependant, I know of nothing that mimics *that* exact functionality in vim, do you?
  • 2
    @rantalicious this was also one of the comments I wanted to read. Im sad I can only give you two upvotes here. Thanks for answering the question.

    I've got smart tabs enabled in every IDE so indenting and spacing is both done with tab, although indenting will stay tabs and spacing will become spaces.

    Where I thought tabs had a big pro it's now clear to me that both spaces and tabs have pros and cons and those pros and cons are exactly the same.
    1. Its editor related some editors prefer spaces, some prefer tabs, some don't care.
  • 2
    PEP 8

    - a Python dev

    PS: thnx for lighting the flame
  • 1
    @salmans pep8 is a bunch of heretics. Heretics I say!!!

    Alone.

    To the wind.

    By myself.

    #onlyTabUsingPythonDev
  • 0
    @rantalicious this is the rule I follow. Tabs for indentation (tabulation) and spaces for alignment (spacing)
  • 0
    @jeffalyanak vim displays hard tabs in any format I like, I doubt it can "detect" how many spaces should be an indent, and then resize them to a given preference, AND still detect alignment (spacing) properly that isn't part of the indentation. Part of the problem here is coding for every single key word in the language.

    Where has setting the tabsize is easy, set it to 2 or 4 or leave it as 8, it's one command and its easy to change.
  • 0
    @brettmoan Why do you think anyone is forcing what editor you use? You're free to choose whatever editor you like.

    If you find soft tabs intolerable I'm sure you know how to format code to your liking. It is just strange you don't understand the purpose or value in another's choice and seem to wish to impose YOUR choice of tab style upon others. Let others use what they use even if you fail to see the utility that isn't their fault.

    And get yourself a decent editor or IDE...of your choosing. No one is forcing you to be a victim or feel offended. Get over it already and use what you want. Unless you're telling me hard tabs are limiting your choice for some reason....?
  • 0
    @brettmoan I'm sorry you took it personally. Use what you want and be happy. 😁
  • 1
    @wildcard nope still broken hah
Add Comment