DEV Community

Cover image for Code Smell 211 - Tab over Spaces

Code Smell 211 - Tab over Spaces

Maxi Contieri on May 06, 2023

Tabs or spaces, are equivalent? TL;DR: Don't use Tabs. It is not a "personal style decision" Problems Readability Compilation error...
Collapse
 
cloutierjo profile image
cloutierjo

How to start a flame war labeled as code smell.

Collapse
 
virtualmachine profile image
ByteCodeProcessor

Last time I used the IDLE that came with python i used tabs and everything worked fine. I did a quick Google search and the IDLE changes tabs to spaces. It's 2023 after our Lord, your text editor should be able to change tabs to spaces by default.

Collapse
 
mcsee profile image
Maxi Contieri

No flame war. Just polite arguments

Collapse
 
moopet profile image
Ben Sinclair
Collapse
 
jonrandy profile image
Jon Randy 🎖️

Tabs vs. Spaces: It's an Accessibility Issue • Adam Tuttle

Tabs cost you nothing and give your team more options. They're the more accessible choice.

favicon adamtuttle.codes
Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

It's not just a11y; different people just find different indentation widths the most comfortable to read and I don't want to force anyone looking at my code to be weirded out by my 3-space indentation preference.

Collapse
 
mcsee profile image
Maxi Contieri

Accessibility is a very good point

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

 Spaces will always look the same, no matter the text editor, font spacing, or IDE used.

This is a disadvantage. Code is not a fucking painting, and wanting everyone reading it to experience it the same way is nothing more than thinly veiled arrogance.

All the other non-arguments are just variations of this or the dishonest attempt to blame anything caused by mixed indentation on tabs. Spaces aren't immune to mixed indentation either; I constantly find files at work (we use spaces as company policy) where someone has committed a change with tabs.

There literally isn't a single good reason for spaces other than wanting to force ones own formatting preferences on others. Spaces are harmful, using them is dumb, defending them is toxic.

Collapse
 
cloutierjo profile image
cloutierjo

I actually arrived to the same conclusion after reading summaries of both sides arguments a few years ago, their is no valid argument to use space!

Collapse
 
ervin_szilagyi profile image
Ervin Szilagyi

TL;DR: Don't use Tabs. It is not a "personal style decision"

With all the respect, but I strongly disagree with this, at least with the first part. I agree that it should be a personal decision, but stating that you should use spaces can be blatantly ignorant towards people who have accessibility needs. I suggest reading this post: reddit.com/r/javascript/comments/c...

Collapse
 
mcsee profile image
Maxi Contieri

interesting post. thanks for mentioning

Collapse
 
yoursunny profile image
Junxiao Shi

go fmt enforces TAB and you shouldn't fight against the official code style.