50 points

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.

permalink
report
reply
43 points

Because other people might have restricted environment which might not suit their preference is not a good reason to level it down IMO.

Also, I think 9 is the best size for indent (matter of preference), do you think I should switch to space so everyone can enjoy this wonderful view I have ?

permalink
report
parent
reply
17 points

Ah, the best kind of indent. A tab and a space.

permalink
report
parent
reply
9 points

Or just set tabsize to 9, that’s the point :)

permalink
report
parent
reply
6 points

It’s not just “might”. Termux is pretty much the only good choice for programming on Android.

I think 9 is the best size for indent (matter of preference), do you think I should switch to space

I think you should switch to an exorcist.

permalink
report
parent
reply
3 points

What’s your point ? You can use vim on termux and set the tabsize to whatever you want for example.

permalink
report
parent
reply
4 points

Why would you ever need 9 other than trolling people on the internet?

permalink
report
parent
reply
4 points

Straight on point!

permalink
report
parent
reply
19 points

What environment are you using that has a hardcoded tab size? I haven’t seen this since typewriters.

Some projects just use tabs as a compressed form of 8 spaces. But that is a sin. Use tab to mean “one indent level” and align with spaces if you need to. (the occasional ASCII art diagram)

permalink
report
parent
reply
7 points

What environment are you using that has a hardcoded tab size?

  • Termux
  • SourceHut
  • “View page source” in the browser
permalink
report
parent
reply
15 points
*

Termux

I think running tabs -N (where N is you preferred tab size) in the terminal should work. This is what I use in my zshrc on desktop.

SourceHut

Yup, they seem to be pretty opinionated here. If you look at the source there is just an inlined style with a single rule pre { tab-size: 8 }. I guess that is what you get when you use opinionated tools. The user’s browser isn’t right, my preference is right!

“View page source” in the browser

On Firefox this uses my default tab size of 4. But I guess changing this default isn’t user-friendly.

permalink
report
parent
reply
4 points

Github uses 8 as a default. It’s configurable though.

permalink
report
parent
reply
3 points

What environment are you using that has a hardcoded tab size?

Microsoft Windows’ Notepad. I have sometimes used that when on a public computer.

permalink
report
parent
reply
13 points

As an embedded software developer that does linux kernel drivers I’ve come to love the tab size 8 indentation level.

I’m paraphrasing: “if your indentation level gets too deep, it’s time to rethink/refactor your function.”

And with tab 8 you’ll notice it rather quick if your function does too much/unrelated stuff.

A function should be short and do one thing only, if possible. It also makes unit testing easier if that’s a requirement.

permalink
report
parent
reply
-1 points

When you’re operating on such a low level of abstraction, it’s no wonder you don’t need deep nesting.

permalink
report
parent
reply
1 point

Oh, I’ve done my fair share of C++ and Python as well. But you got to agree with me that when you are on your fourth indented “if case” it’s time to step back and think about what you are trying to achieve. I mean it’s probably going to work, but probably also very hard to maintain that type of code.

permalink
report
parent
reply
10 points

This is the biggest problem with tabs. Too many tools don’t let you adjust the size (or make it very difficult). This is the only reason I usually prefer spaces (only very slightly).

My dream solution is elastic tabstops and I’ve posted about it here before a few months ago. The problem with wanting elastic tabstops is that it seriously compounds the issue of “editors don’t properly support it”

https://nickgravgaard.com/elastic-tabstops/

permalink
report
parent
reply
38 points

Another accessibility reason for tabs: when using a braille display, each space takes up one character cell, so indenting with four spaces eats up four cells. Indenting three times with four spaces each eats up 12 characters already. Tabs only take one character cell each, so three indents = three character cells used.

The fact that there (I assume?) isn’t a braille oriented text editor that can handle space-based indentation in a smarter way is a bit depressing. Maybe the solution should be better tools based around accessibility rather than convincing everyone to switch to tabs, which is a project that will just never succeed.

permalink
report
reply
12 points

So your fix is “convince all the people that want/need the better handling to use a specific editor?” - perhaps it’s a smaller number of people, but do you not see the irony there?

I honestly don’t care about tabs vs. spaces, but if there’s a low cost change in my setup that makes it easier on others, why not?

permalink
report
parent
reply
15 points

My spontaneous reaction is that making some sort of braille oriented setting for some or hopefully most editors used by people with braille displays (I have no idea if using a “normal” editor even makes sense if you’re using a braille display) is the most pragmatic solution to their screens being taking up by spaces.

First of all, convincing everyone to use tabs is a monumental task. Convincing people with braille displays to use more convenient tools on the other hand seems pretty easy, why wouldn’t you want to use more convenient tools?

Secondly, there is a large amount of code written with spaces today, so even if people switch with tabs in the future you might still want to be able to read legacy code.

Thirdly, I don’t think that the choice of tabs vs. spaces is completely arbitrary because of alignment. Using tabs for indentation and space for alignment leads to a lot more micro management of whitespace compared to just using spaces. I would guess that alignment isn’t very braille friendly anyway, but it does make the code more readable for other people. Having a good braille editor affordance might be closer to letting us have our cake and eat it too.

Of course, I don’t know what this would look like exactly, and maybe there’s some sort of obstacle that I’m overlooking, I do want to be clear that this is just of the top of my head as someone who has never used a braille display.

permalink
report
parent
reply
0 points

There’s a difference between doing something that’s “easier” and what’s right.

Whether there is more legacy code with spaces or tabs is irrelevant. Most of the code that will be written hasn’t been written yet.

I disagree with you on “micromanagement” of spaces vs. tabs, that is nonsense. Set up a formatter for commits and set your IDE to display how you want.

The pragmatic view on one or the other is that for a one group of people, using tabs appears to be significantly better, and for everyone else, it barely matters at all, except as personal preference.

That being said, I’m not vision impaired, so I don’t know what the preference would be.

The reason we’re even talking about it is that someone that has studied it from an accessibility perspective has asserted that tabs would be preferred.

permalink
report
parent
reply
3 points
*
Deleted by creator
permalink
report
parent
reply
7 points
*
Deleted by creator
permalink
report
parent
reply
2 points

That reminds me of those times when back on reddit some dev showed up to present their new GUI library. Bragging about how they were better than Qt devs etc. (even though they didn’t implement the hard parts, like working text fields or tables)

After some time a bunch of people had enough and started bullying those guys into submission about accessibility. After some time, every of those toolkits had support or at least plans for supporting screenreaders. Eventually, AccessKit became a thing.

Good times.

permalink
report
parent
reply

Arguing that it’s invincible to convince people at large to adopt tabs over spaces with good arguments is a ridiculous statement

I do actually think that it is very hard to convince basically every programmer of something, no matter how good arguments you have.

Also, without knowing much about the issue, it sounds a bit like the tooling for people using braille displays isn’t very good and fixing that is maybe also worth advocating for, perhaps it’s even a strategy for advocacy that is more effective?

permalink
report
parent
reply
4 points

Yeah. It is depressing.

I’ve always wanted an accessibility feature that uses haptic feedback to mimic braille patterns for reading purposes too.

In general a lot of creative stuff can be done if we focused on it even a tiny bit more.

permalink
report
parent
reply
38 points

I wish every language had a gofmt, this is such a non-debate (tabs are indentation, spaces are alignment)

permalink
report
reply
5 points

rustfmt

permalink
report
parent
reply
5 points

And over gofmt, rustfmt lets you set settings for the project. Keeps the code looking how I want, and contributers don’t have to care.

permalink
report
parent
reply
1 point

The absence of settings in gofmt is a feature. The kind of basic formatting it handles is not worth having opinions about.

permalink
report
parent
reply
37 points

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

permalink
report
reply
16 points

“Error: syntax error on line 1”

…shit

permalink
report
parent
reply
8 points

Great, no scrolling through thousands of lines to find the right one!

permalink
report
parent
reply
2 points

Scrolling to a line number seems inefficient.

permalink
report
parent
reply
11 points

My program, written in the whitespace language, ruined.

CURSE YOU PERRY THE PLATYPUS!

permalink
report
parent
reply
2 points

Now next time I read anything about why any Python libraries are named what they are named, I’m going to hear Dr Doofenschmirtz voice. Thank you for that.

permalink
report
parent
reply
34 points
*

Code formatter and run auto format

permalink
report
reply
5 points
*

Holy wars are fun, but this is the answer.

At least this way the holy war takes place in commits to change the formatting file.

Unless go, in which case the holy war is now everyone who hates go format rewriting the code in a different language.

permalink
report
parent
reply
1 point
*
Deleted by creator
permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

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 !webdev@programming.dev



Community stats

  • 3.5K

    Monthly active users

  • 1.6K

    Posts

  • 26K

    Comments