630
fixed rule (lemmy.blahaj.zone)
submitted 1 year ago by ambrosiaforest to c/196
you are viewing a single comment's thread
view the rest of the comments
[-] kryptonianCodeMonkey@lemmy.world 24 points 1 year ago* (last edited 1 year ago)

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!

[-] ToastedPlanet 6 points 1 year ago

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.

[-] brown567@sh.itjust.works 14 points 1 year ago

I think they mean the word 'tabs'

[-] ToastedPlanet 3 points 1 year ago

oh lol, I missed that =p

[-] ChairmanMeow@programming.dev 4 points 1 year ago

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.

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

[-] ToastedPlanet 2 points 1 year ago

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

this post was submitted on 10 Feb 2024
630 points (100.0% liked)

196

17022 readers
671 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

If you have any questions, feel free to contact us on our matrix channel.

founded 2 years ago
MODERATORS