this post was submitted on 05 Sep 2023
1 points (100.0% liked)

Programming

17031 readers
371 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
top 12 comments
sorted by: hot top controversial new old
[–] [email protected] 0 points 1 year ago (1 children)

The argument for having tabs adjust depending on your ide sounds better than it is in practice. Someone formatting code to look nice with width 4 will look horrendous for someone who uses width 8.

Spaces makes it uniform and captures the exact style the original dev intended

[–] [email protected] 0 points 1 year ago (1 children)

If you have your tab width set on 8, that is on you. You will also set your IDE to insert 8 spaces when you press TAB and I will cry when I have to give you a code review.

When I indent my code, I am indicating that I am in a nested block. I don't care if, on your screen, that indent is 2, 3, or 4 characters.

[–] [email protected] 0 points 1 year ago (1 children)

Anarchist: tab with set to 1

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

That's fine, when I view it I will get my preferred tab width. This situation is only anarchist with spaces, with tabs they are just a masochist.

[–] [email protected] 0 points 1 year ago (1 children)

Neither tabs or spaces are good. The correct way is to leave no whitespace in the code at all. It's unnecessary and adds to processing time.

Everyone should aim for 1LOC per commit

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

My program, written in the whitespace language, ruined.

CURSE YOU PERRY THE PLATYPUS!

[–] [email protected] -1 points 1 year ago* (last edited 1 year ago)

Interesting take. I prefer spaces because each piece of code that I see with tabs has an implicit tabsize you really need to have if you don't want the code to look ugly - especially if the person has been mixing tabs and spaces - and they usually do. Sometimes unadvertently.

When you remove all tabs at least everyone is on the same page.

To the actual problem raised by the article:

I have ADHD. Two spaces per indent makes it damn near impossible for me to scan code. My brain gets too distracted by the visual noise. Someone who’s visually impaired might bump their font size up really large, and need to scale up or down the amount of space per indent. Someone might just prefer it because…

I wonder if it could be possible to adjust the "indent number of spaces you see" in code editors. Code editors are able to figure out what are indents and what are not, so in theory it should be possible. Perhaps that would be an idea for a new feature?

[–] [email protected] 0 points 1 year ago (1 children)

Tabs for indent, spaces for alignment. This is the way, I can't believe people are still fighting that ?

[–] [email protected] -1 points 1 year ago* (last edited 1 year ago)

Anything for indent (barely matters, as long as the editor forces it to stay consistent), and fuck alignment, just put things on a new line.

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

I consider tabs for indentation a failed concept.

The idea is good, but it evidently failed. Most guidelines and newer Tools recommend or require or use spaces for indent. They have their reasons too.

The prevalence of spaces makes it hard to make a contrary argument for tabs. By now, I don't think it's worth even if it had reasonable advantages.

Editors/IDEs that parse syntax can adjust space indent too. A mixture for indent and alignment is not obvious for everyone (I always display whitespace in my editors and am deliberate and consistent, but many people and editor defaults won't be). Some defaults of four or eight space-width tab display is atrociously wasteful and inaccessible.

Spaces are a good enough baseline. It works well enough. And most importantly it works consistently. That's why it won in prevalence and use.

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

I've always wondered why some people tout "forcing a consistent appearance across environments" as a pro for spaces. That's a bad thing.

To be honest I'm surprised code format converters aren't ubiquitous. Let the repo have it's master format, enforced on commit. Then converters translate into each developer's preferred standard dialect on checkout and back again on commit.

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

Tabs let you define how big you want each indent to be

…except when they don't. Many common environments have a hardcoded tab size of 8, which is insanely big for using it for indentation.