Tabs or spaces?

What do you prefer? For my Python code, I use 4 spaces (because of pylint and pep8), but for other files - 4-width tabs.

1 Like

i prefer tabs myself as i see visually where the code is grouped and not stray into other code blocks.

  1. I’ve always thought it was merely a matter of taste.
  2. I can’t figure out a good reason to use spaces—they’re harder to use, easier to break, worse to display… for no added benefit.

However, it seems that spaces managed to win the tabs vs spaces war for God knows what strange reason. In my area of expertise (PHP) most open source projects nowadays use spaces, PSR-2 requires spaces and the Stack Overflow Developer Survey 2015 clearly shows that only n00bs use tabs.

For reference, my co-workers seem to use whatever default setting their current editor has—even if it doesn’t match current file indentation.

The Genie programming language requires tabs for block indentation, but can be configured with in-file metadata to use spaces instead (like the first line of this file).

That approach sounded pretty intrusive to me at first, but I think I like the idea of having the spaces/tabs decision determined formally like that: deviate from the default if you like, but do so explicitly or else the code won’t compile.

I prefer spaces over tabs. Files always appear the same, no matter what editor or viewer our team is using.