this post was submitted on 03 Oct 2021
297 points (98.1% liked)

Programmer Humor

33125 readers
452 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 23 comments
sorted by: hot top controversial new old
[–] [email protected] 21 points 2 years ago (3 children)

I will never understand why people are so set on spaces...

[–] [email protected] 11 points 2 years ago (2 children)
[–] [email protected] 9 points 2 years ago
[–] [email protected] 8 points 2 years ago

I use spaces, but tabs use fewer characters, are easier to edit and allow for people to have custom indentation levels...

[–] [email protected] 9 points 2 years ago* (last edited 2 years ago) (1 children)

If you’re using monospaced fonts for writing code (please tell me you are) spaces make sure that the code will look roughly the same on everyone’s machine.

def function(paramX: str,
             paramY: str,
             paramZ: str) -> int:
  pass

If I’d used tabs, the second and third parameter might not align with the first.

Also, left-side indentation is only a small part of the overall whitespace in code. You’re adding whitespace even when you write x = y. Spaces make sure that this whitespace around the = grows in the same scale as the indentation.

[–] [email protected] 6 points 2 years ago (1 children)

Yes but it's not your job to make sure your code looks the same for everyone else. If they'd prefer to read it with a different tab size, maybe they're using a smaller screen, or a larger one because of vision issues there's no reason they shouldn't. You can use an optional editor config if you want it to be able to look the same for others.

[–] [email protected] 4 points 2 years ago (1 children)

It makes a difference when you’re working on a large project with lots of people. Even Linux mandates 1 tab = 8 spaces.

The only argument i see in favour of tabs is the “i can change the width on my own machine!” which isn’t very convincing if you are working on a team and need to follow conventions every time you commit code. The indentation will keep looking weird on your machine.

[–] [email protected] 3 points 2 years ago (1 children)

Yes so you can choose to follow that convention, but it being adjustable for reading is very useful for reading on different screensizes or with eyesight issues. Why not just set what you want in an editor config?

[–] [email protected] 3 points 2 years ago (1 children)

Well, life is about trade-offs and neither spaces or tabs are perfect in every scenario, but the industry overall prefers spaces over tabs nowadays and the tooling reflects that too. For me personally, as long as a project is consistent in its formatting and developers don't need to fight its tooling, I'm happy with either. We can yak shave all we want (and lots of people are doing that on the internets) but I hope I at least answered your initial question about why people prefer spaces over tabs.

[–] [email protected] 2 points 2 years ago

That's fair, you did thank you!

[–] [email protected] 3 points 2 years ago (1 children)

I will never understand why people are so set on spaces...

They just never really understood tabs. If they did, they wouldn't be sitting there counting how many times they hit the space bar!

[–] [email protected] 6 points 2 years ago

We understand tabs perfectly, we press the tab bar and our editor inserts 4 spaces like god intended

[–] [email protected] 11 points 2 years ago

That joke in the second panel though...

[–] [email protected] 8 points 3 years ago (2 children)

using spaces: google, microsoft, apple

using tabs: linux, gnu

[–] [email protected] 11 points 3 years ago (1 children)

Why is this a line graph? What's on the X axis?

[–] [email protected] 5 points 2 years ago

Casualties.

[–] [email protected] 4 points 3 years ago (1 children)
[–] [email protected] 10 points 2 years ago (1 children)

Google employees who work on the Linux kernel.

[–] [email protected] 3 points 2 years ago (1 children)

Just a heads up: You and I have fallen for the classic blunder on replying to a 1-year-old thread.

[–] [email protected] 3 points 2 years ago

Classic lemmy

[–] [email protected] 1 points 3 years ago (1 children)
[–] [email protected] 1 points 2 years ago
[–] [email protected] 1 points 3 years ago* (last edited 3 years ago)

Hot take: Tabs are the objectively correct way to do indentation. The main argument I have seen in favor of spaces is that they give you finer control over how the code looks, but semantically, one tab is one level of indentation, and the exact appearance of a tab is best left to editor preference. Nonetheless, I use spaces because everyone else uses spaces, and I would rather be consistent with existing code bases than bikeshed over ultimately unimportant concerns. I suspect this is the reason why spaces became so popular in the first place.

load more comments
view more: next ›