this post was submitted on 10 Feb 2024
594 points (96.8% liked)

196

16423 readers
2199 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] kryptonianCodeMonkey 24 points 8 months ago* (last edited 8 months ago) (1 children)

Tabs should be 4 spaces because it can be replaced 1:1 with "tabs".

For example...

def foo():
    if bar:
        foobar()

vs...

def foo():
tabsif bar:
tabstabsfoobar()

Put that in your code review, cowards!

[–] [email protected] 6 points 8 months ago (2 children)

Only if a person's machine is set to a tab size of four spaces. By this logic, we would need eight spaces for the people with a larger tab size of eight on their machines so they could be 1:1. Minimizing horizontal space is ideal as not everyone has huge horizontal monitor space to work with. But, everyone has infinite vertical space with scrolling.

[–] [email protected] 14 points 8 months ago (1 children)

I think they mean the word 'tabs'

[–] [email protected] 3 points 8 months ago

oh lol, I missed that =p

[–] [email protected] 4 points 8 months ago (2 children)

If your code takes up so much horizontal space with 4-space tabs, you're putting too much on one line or indenting too deep. 4-space tabs keeps your line length manageable.

[–] kryptonianCodeMonkey 2 points 8 months ago

If you have to nest more than 2 layers, rewrite your code.

[–] [email protected] 1 points 8 months ago

Or you're using four spaces per tab, just throwing that out there. =p