this post was submitted on 09 Aug 2023
8 points (100.0% liked)

Programming Polls

129 readers
1 users here now

Welcome to the programming polls community! This is a place where you can run polls related to programming

For questions not related to being a poll theres communities such as [email protected] instead and for trivia theres [email protected]

As lemmy doesnt have a built in poll system if you want to run a multiple choice poll you can just make each option its own reply and people can vote by upvoting

founded 1 year ago
MODERATORS
8
submitted 1 year ago* (last edited 1 year ago) by Ategon to c/polls
all 20 comments
sorted by: hot top controversial new old
[–] Ategon 33 points 1 year ago
[–] Ategon 22 points 1 year ago
[–] spartanatreyu 6 points 1 year ago (3 children)
[–] CameronDev 7 points 1 year ago (1 children)

Your link doesn't seem to weigh super heavily on the "tabs for indentation" as a rule, only that tabs should never be for alignment.

Tabs for alignment is definitely a recipe for madness.

Interestingly, tabs for alignment is the correct method for word processors, so it's backwards for code :/

[–] spartanatreyu 1 points 1 year ago (1 children)

True, the link doesn't go through tabs for indentation, but tabs should already be used for indentation for accessibility

[–] CameronDev 3 points 1 year ago (1 children)

That could be argued for years, ill leave your preference up to you :) I'm personally in the spaces for indent camp, but realistically, as long as you match the existing codebase, it doesn't matter.

[–] spartanatreyu 2 points 1 year ago (1 children)

I don't think there's any new arguments anymore, it was all settled long ago.

  • Tabs were always useful for accessibility and DX.
  • Spaces were useful 2-3 decades ago when not all editors could handle tabs yet.

But now all editors handle tabs.

[–] CameronDev 2 points 1 year ago (1 children)

And yet, the debate still rages :D I am not sold by the tab arguments, and your probably not gonna be sold on the spaces arguments. As long as we don't fuck with each-others codebase, it really doesn't matter too much.

The accessibility argument is interesting, but setting your code style to use a sufficiently large amount of spaces, and avoiding horrifically nested code seems a valid solution there as well (XML would be a strong case for tabs, other languages less so). Maybe when my eyes start to age I'll care more about adjustable tabs :/

[–] spartanatreyu 2 points 1 year ago (2 children)

There isn't a debate anymore, the points have already been stated.

The only reason people still talk about it is that there's always developers learning the points for the first time.

Don't worry about your own eyes in some vague future, worry about other's eyes now.

[–] CameronDev 1 points 1 year ago (1 children)

I think the reason that people still talk about it is that there isn't a compelling reason on either side. There is just a series of slight benefits and drawbacks. Tabs are slightly better on braille readers, spaces are easier for consistency (when tools don't respect .editorconfig), blah blah blah. No one is being entirely excluded due to either option being used, so it's really a personal/team style decision.

[–] spartanatreyu 2 points 1 year ago (1 children)

Tabs are better than just for blind users.

Most users want an indentation size of 4 so for the rest of this comment we'll just call that one the default size.

Tabs

Tabs at default/any size

  • Blind people don't care about the tab size, just that there's tabs.
  • Keyboard users don't care about the tab size, just that there's tabs (because it's only one key to change indentation levels).
  • Manual formatters don't care about tab size, just that there's tabs (because you can't mess anything up inside the tab itself, but you can with space indentation)

Tabs at larger than default size

  • Verbose language (e.g. FactoryFactoryFactory) users tend to care about tab size and put the tab size up to 8 to make it easier to read. These users tend to use tabs because it's fewer keys.
  • Zen mode users (AKA visual overload users) tend to use larger tab sizes

Tabs at smaller than default size

  • Users with poorer vision who increase the size of the code while trying to fit as much on the display as possible

Tabs at variable sizes

  • Users who move their code between a laptop display and a larger display
  • Users who use terminal splitting / tiling window managers (as a code viewport becomes more squashed, the indentation adjusts to fit the same amount of code in the viewport)

Spaces

Spaced indentation at smaller than default size

  • Users are unaware of reasons why to use tabs
  • Users coding in C99 on an 80 character wide shell

Spaced indentation at default size

  • Working on a project or using a style guide created by developers who originally coded in C99 on an 80 character wide shell

Mixed Indentations

[–] CameronDev 1 points 1 year ago* (last edited 1 year ago)

Spaces don't require additional key presses, you press tab and it puts in X spaces. No one should be using the spacebar except for when you need to precisely align things. Arguably, no one should be pressing the tab key either, as most IDEs can automatically indent for you, and it doesn't requires tabs or spaces.

Annecdotally, tabs don't display nicely on some braille devices (saw someone mention this on the prettier tabs discussion while researching yesterday). This may come down to the specific device they use, or it could be entirely false, but all the arguments for tabs/spaces a11y have been anecdotal.

These are all reasons to prefer tabs, but none are reasons to require tabs. And hence, teams will make their own decisions based on what annoys/suits them most.

https://blog.jetbrains.com/dotnet/2022/08/11/virtual-formatter-in-resharper-2022-2/ https://github.com/prettier/prettier/issues/7475#issuecomment-668544890 - pro tabs

https://github.com/prettier/prettier/issues/7475#issuecomment-1169470712 - pro spaces, with some arguments for tabs

https://github.com/prettier/prettier/issues/7475#issuecomment-1169934190 - claims to be blind, no preference either way

Unfortunately I can't find the tab display complaint, but it was anecdotal anyway. No one on the internet would lie...

[–] colorado 2 points 1 year ago (1 children)

I don't ever bother alignment. That is nuts.

[–] astraeus 3 points 1 year ago

yaml has entered the chat

[–] victron 1 points 1 year ago

I have some serious refactoring to do.

[–] Ategon 5 points 1 year ago (2 children)
[–] szczuroarturo 4 points 1 year ago

Automatic one provided by your IDE. In my case pretty printer in sap gui

[–] [email protected] 2 points 1 year ago

UTF8 no-break spaces!

[–] RadicalKittenWanabe 2 points 1 year ago

The best indentation should be like any style rule chosen by the project team.

So, I guess it should be defined in the source repository