jhartikainen•

tl;dr: I didn't configure my tools to display and handle tab-width correctly, thus spaces are better.

I mean it's a reasonably written article but that's really what it boiled down to.

10
nyxinOPfront-end•

I didn't configure my tools to display and handle spaces correctly, thus spaces are better.

What is the "correct" configuration for tabs? Is a "tab" equal to 2 spaces? 4 spaces? 8 spaces? Every person will have their opinion about what is the correct "tab spacing" (which largely depends on their screen real estate imo) but a space will always be one space when it's rendered. If tabs were a standard, fixed amount of space universally (so there is no "correct" or "incorrect" configuration for tabs) this wouldn't be an issue.

(not the author of the article; just putting in my 2¢)

0
jhartikainen•

Yeah that's certainly true. But that's one benefit of tabs. I don't want to argue for either method, but I think the tab-width is often a bit misunderstood.

Here is code with tab width 2:

func foo() {
  if(faa) {
    //blah
  }
}

Here is the same code except with tab-width 4

func foo() {
    if(faa) {
        //blah
    }
}

Note that the indentation levels remain correct. Tabs effectively let you use the tab width you prefer regardless of what the preference of another user is. And considering how picky people sometimes are about small nuances like that, it seems like a nice feature :D

3
nyxinOPfront-end•

That's a very fair argument for tabs! You could even argue that people like me who use spaces (technically I use tab that converts to spaces on save to try and bridge both worlds) screw things up because of that feature when we use spaces!

Where it gets murky is when you're sharing code between platforms and a team of developers that are mixed between tabs and spaces.

Really you could say that the argument for using spaces is that somewhere, somebody started doing it and screwed it up for everyone else, so we should all use spaces now. ¯\(ツ)/¯

0
LimbRetrieval-Bot•

I have retrieved these for you _ _


^^ To prevent anymore lost limbs throughout Reddit, correctly escape the arms and shoulders by typing the shrug as ¯\\\_(ツ)_/¯ or ¯\\\_(ツ)\_/¯

^^Click here to see why this is necessary

1
[deleted]•

I think that's a flimsy argument.

What's the "correct" number of spaces for indentation? 2 spaces? 4 spaces? 8 spaces? Every person will have their opinion about what is the correct number of "spaces."

3
Rev1917-2017•

A tab is recorded as 1 character in the code. So if I configure my tabs to be 2 spaces, and my buddy configures his tabs to be 4 spaces then it will still just be 1 character in the code. Everyone configures their tabs their way. Spaces, on the other hand, are always only 1 space.

1
Goliander•

Back when the typewriter was a thing, a tab was a 'tab stop', a little moving mechanical stop you ratcheted along a notched bar. That is how you indent. If you want it smaller, you make it smaller. In this case, you define how many spaces a tab is. There is no other way to interpret this, you either get it, or you use separate spaces, like a fucking idiot.

6
bethevoid•

Some of the smartest devs I've ever worked with couldn't comprehend this.

0
[deleted]•

I don't think the argument between tabs and spaces will exist much longer, at least not for those developers that use an IDE that supports smart indentation.

Best solution: Tab developers can use tabs, which are converted into spaces but treated functionally the same in the IDE.

4
nyxinOPfront-end•

Best solution: Tab developers can use tabs, which are converted into spaces but treated functionally the same in the IDE.

I think its worth pointing out that (im assuming) most people who do uses spaces "functionally" use tabs that are converted spaces; not that they're literally typing out space``space``space``space for the desired index-spacing.

I agree this is the best solution for the issue though.

3
[deleted]•

Hahaha, you might be surprised. I've met people that will use 8 spaces for indentation and type out every single one. I can't imagine.

2
ebinnion•

Sounds great, as long as it's the other way around and the indentation is converted into tabs. 😁

1

I believe in Eslint

2
flipperdeflip•

Best way to deal with a discussion about tabs vs spaces is to turn off the computer and get drunk instead.

1