DEV Community

loading...

Discussion on: Who Killed The Tab?

Collapse
darkwiiplayer profile image
DarkWiiPlayer • Edited

Tabs. Why? Because I use 3-space indentation. Do you want my 3-space indentation? No? With tabs you can just configure it to whatever you want. With spaces? Good luck, you're screwed.

I have yet to see a single good argument for spaces, and for tabs there are exactly two:

  • Semantics (This does have practical implications, for example when regexing through your code)
  • Configurability

The dumbest argument for spaces I've heard is (Paraphrasing):

If I use tabs in my projects, I get too many pull-requests using spaces and either have to fix it or, if I don't notice, the code gets messed up

Which, in principle, applies the exact same way the other way around, so it's really just another way of saying "everyone else is doing it"


My theory for why spaces became popular:

They Look the same Everywhere

You can write some code on one editor, then open it in some other editor and the indentation is exactly as you left it. I guess you could blame modern editors for not adopting something shorter than 8-space tabs as a default, but I think it's a realistic demand that users either configure their editor to how they like them or just deal with it if it's a super tiny edit.

This reminds me a lot of how many bad practices in the front-end world came to be: people want their creations to look the same everywhere, instead of setting guidelines and letting the browser handle the specifics. In that sense, spaces are the px of the source; tabs are the em.

Collapse
merri profile image
Vesa Piittinen • Edited

There has been a strong push for "Developer Experience" (which has some stuff that I think makes things actually worse...) so maybe we could start Developer A11Y push, too.

You can find space hacks everywhere now, for example Styled Components has bits of code that determines level of indentation by number of spaces on a certain line. I expect the logic to fail if tabs were used. It also relies on Prettier to exist.

Collapse
bytebodger profile image
Adam Nathaniel Davis Author

Great points. And yeah... I think the they look the same Everywhere argument sways a lot of people. But that argument also ticks me off. Everything else about modern IDEs is designed to ensure that we can all look at the same code - but we can all view it in a way that is best for each of us. But with spaces, that ability is taken away. It's a nasty brand of arrogance that says, "You must look at this code in the exact same way that I look at it."

I won't repeat a ton of verbiage here, but if you read down a few comments, you'll see where I compared this to code coloring. For some reason, no one thinks it'd be cool to force every dev to read a given code file with the same coloring scheme. (And thank goodness that they don't.) But they think it's perfectly kosher to dictate that we must all read that code with the exact same indentation.

Collapse
redhap profile image
HAP • Edited

As a curmudgeonly 50-year-old software engineer, I do like spaces vs tabs. And, yes, I like it because it is consistent. Sometimes I use an IDE. Sometimes I use vi (which I occasionally call six, just to annoy).

But the thing I do find annoying that, more and more, I'm seeing development organizations using prettifiers and reformatters to enforce sameness across code. Thus it becomes annoying when you work on a piece of code just to have a bot either reformat it or wag its finger at you saying it's too complex.

I, for better or worse, feel that it is better for developers to be exposed to more diversity in coding (beyond the whole spaces/tabs thing) as, no matter where you go, you're going to see some differences anyway. Sometimes these differences can help you improve your own code by learning tips and tricks that reformatters are often configured to rewrite.

Ugh. End rant.

Thread Thread
bytebodger profile image
Adam Nathaniel Davis Author • Edited

Sometimes I use vi (which I occasionally call six, just to annoy).

This sentence alone makes me like you.

But the thing I do find annoying that, more and more, I'm seeing development organizations using prettifiers and reformatters to enforce sameness across code.

I mostly agree with you. The only "modification" I'd add is that: I don't mind those tools. If they work for you (or your team), then, great! I only "mind" those tools when I feel that I almost have to use them to work around the other arbitrary rules that have been forced upon us by the standards / style guides.

I, for better or worse, feel that it is better for developers to be exposed to more diversity in coding (beyond the whole spaces/tabs thing) as, no matter where you go, you're going to see some differences anyway. Sometimes these differences can help you improve your own code by learning tips and tricks that reformatters are often configured to rewrite.

Truly, this is a beautiful sentiment. I feel that it kinda falls in line with other things I've blogged about in the past. But I also think it might become its own blog topic in the not-too-distant future.

At some point, in the desperate search for code "quality", people decided that this could be accomplished with slavish conformity and sameness.

But "quality" is more than just ensuring that everyone's code looks like a carbon copy. And... to your point, there are some wonderful "a-ha!" moments to be had when you're perusing someone else's code that isn't "wrong" - but is just a little different from your own.

Thread Thread
v6 profile image
🦄N B🛡

which I occasionally call six, just to annoy

Step your troll game up a level of annoyance and call it eleven. You're welcome.