this post was submitted on 28 Feb 2024
616 points (97.2% liked)

Programmer Humor

19735 readers
619 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
616
wait what (pawb.social)
submitted 9 months ago* (last edited 9 months ago) by [email protected] to c/[email protected]
 
top 50 comments
sorted by: hot top controversial new old
[–] SzethFriendOfNimi 211 points 9 months ago* (last edited 9 months ago) (3 children)

I know it’s a joke but I prefer the tab option. It’s easy to convert tabs to any particular spacing or code point width. It can also vary, if wanted, based on terminal or editor type.

People with worse eyesight can have a wider indentation while those who choose can opt for something more compact

[–] fluckx 55 points 9 months ago* (last edited 9 months ago) (2 children)

Honestly I always preferred tabs for indentation and spaces for aligning. It doesn't break anyone's experience. And if somebody wants ~~two spaces for~~ a two-space-tab-width for indentation and other people prefer four. That will work just fine.

I hate seeing 2 space indents. Unreadable AF ( to me ). At least this way I can easily work in the same codebase without somebody being annoyed ( except for the crying about the tabs )

[–] [email protected] 10 points 9 months ago (1 children)

Why not tabs for both indentation and alignment? (Actually, I see indentation as just a specific use of alignment.) Word processors have been doing it for decades (and typewriters for over a century!). Surely we can convince our code processors to use user-definable, fixed position tabs instead of relative position "tab = x spaces".

Keeping the [TAB] character in the file then allows everyone the layout they like.

Or has working solo for 40 years fried my brain?

[–] fluckx 7 points 9 months ago (7 children)

What I mean with tab = x spaces is only visually and not actually ( there will ( obviously) still be a tab character in my preference. Not sure if that was clear.

Because alignment are fixed characters compared to indentation. For indentation the only question is how many characters the next indentation needs to be.

For alignment it is not fixed. As an example of PHP code:

function test(&obj) {
$obj->doSomething()
....->doSomethingElse()
}

The dots would be spaces because in IDEs people generally use a font where every character is equally wide.

If I would tab again instead of spaces it could work out if my tab length display is ( for one or more ) adds up to the width of the variable $obj. If somebody else has a tab width of 2 rather than somebody who has 3. It would only align for one of the two people.

Does make sense? I typed it out after a gym session on my phone.

Additionally. The whole problem is resolved by using spaces for both alignment and indentation. But in the cursor would still jump one space at a time rather than the whole tab ( although there are keyboard shortcuts for jumping words which would jump all of em.

I don't know. Call me old fashioned. I like what I like :/

load more comments (7 replies)
load more comments (1 replies)
[–] [email protected] 38 points 9 months ago (5 children)

I can't imagine it would be difficult for an IDE to scale the width of spaces found at the start of a line, to emulate this same customization while still preserving my sanity as a fervent space-indenter. I've never seen an IDE that does this, but it'd be an interesting compromise.

[–] [email protected] 26 points 9 months ago (1 children)

It's not difficult at all, and many editors and IDEs already support this, making the entire point moot. Just do whatever the style guide says. I'm into PHP and Python so for me it's spaces all the way.

[–] [email protected] 8 points 9 months ago (3 children)

How can it tell the difference between spaces used for indentation and spaces used for alignment, if you use the same character for both?

[–] [email protected] 8 points 9 months ago

I guess the indention sizer thing knows how the formater works and adjusts accordingly. I can't imagine it would be too much of a problem.

Iirc Jetbrain IDEs has a feature called dynamic tabs/space (or something like that) which uses exclusively tabs until it needs to align something and a tab doesn't fit, so it uses a few spaces instead.

load more comments (2 replies)
load more comments (4 replies)
[–] [email protected] 11 points 9 months ago

I agree, tabs are better but I have been using spaces for so long I can't even imagine switching to tabs. also I'd have to reformat all my abandoned projects.

[–] [email protected] 80 points 9 months ago (12 children)

Tabs are objectively the better choice as it allows each dev individually to decide tab width in their editors. Spaces in contrast don't allow this same flexibility as they are used for much more than simply indentation, for example you likely put a space after each argument or operator IE func(arg1, arg2) or 1 + 2.

[–] [email protected] 15 points 9 months ago (4 children)

Also, a lot of editors won't unindent on backspace of spaces indentation, so I end up messing up the indentation with a 3/4 indent

load more comments (4 replies)
load more comments (11 replies)
[–] [email protected] 70 points 9 months ago (4 children)

The sole purpose of the tab key is for instructing the editor to insert four spaces.

[–] [email protected] 41 points 9 months ago (1 children)

To insert a........ TAB. Not four or any n number of space but TAB

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

After years of ass-whopping by python interpreter for stray tab characters, I'm now mentally rejecting the existence of tab character in my computing devices.

[–] [email protected] 8 points 9 months ago

Isnt that only because you "mixed" spaces with tabs? I have had no issues with python and tabs with no spaces for intendation

load more comments (1 replies)
[–] Buddahriffic 18 points 9 months ago (1 children)

*three spaces.

Actually, let's make that two.

[–] [email protected] 6 points 9 months ago (1 children)
load more comments (1 replies)
[–] [email protected] 10 points 9 months ago (2 children)

Cycling through buttons, atl+tab, Ctrl+tab, some other fourth thing.

load more comments (2 replies)
load more comments (1 replies)
[–] Unlearned9545 44 points 9 months ago

Team Tab Supremacy Unite!

[–] Fades 43 points 9 months ago

Hell yeah tabs

[–] hakunawazo 42 points 9 months ago (1 children)

Let's just avoid indentation at all (jk).
Always remember:

[–] hansl 8 points 9 months ago

“He's me.” - Obi Wan Kenobi

[–] [email protected] 36 points 9 months ago

As a fan of tabs I see this as an absolute win

[–] aeharding 34 points 9 months ago (1 children)

Is this real or am I eating the onion

[–] TootSweet 43 points 9 months ago (1 children)

You're eating the onion. I could see some government agency deciding that they as an agency would standardize on tabs, though even that would be a stretch. But not the White House.

[–] bisby 25 points 9 months ago (1 children)
[–] [email protected] 30 points 9 months ago* (last edited 9 months ago) (2 children)

By adopting a tab-delimited approach to softwaremaking, ONCD is ensuring that the technical community’s expertise is reflected in how the Federal Government approaches these inconsistencies. Creators of software can have an outsized impact on the Nation’s shared security by factoring standardized tabulations into the development process.

For anyone who doesn’t want to read that whole thing.

[–] [email protected] 20 points 9 months ago

Lol I almost fell for it. I just Ctrl+F'd the link, no occurence of "tab" in the press release :D

load more comments (1 replies)
[–] [email protected] 19 points 9 months ago

Feels relevant

Just make everything Shittier

[–] treechicken 18 points 9 months ago* (last edited 9 months ago)

Man how are we gonna write all of our Whitespace programs now?

[–] [email protected] 18 points 9 months ago (3 children)

Spaces are supiror because its easier to text boxes.

I mean where even is the tab on my phone?

[–] [email protected] 20 points 9 months ago* (last edited 9 months ago)
Right  
	here

Edit: til tabs make code blocks in lemmy

[–] Potatos_are_not_friends 13 points 9 months ago (2 children)

Another person who codes on their phone.

I bow to your greatness.

[–] [email protected] 7 points 9 months ago

I actually does code a bit in phone(and only codes in phone) and still preffer tabs. Hate it when some editors auto spaceify it. Also you can have tabs on keyboard by installing abother keyboard app

load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 17 points 9 months ago (8 children)

The correct answer is, was and always has been elastic tabstops

load more comments (8 replies)
[–] [email protected] 16 points 9 months ago* (last edited 9 months ago) (1 children)

Maybe it is time for another civil war.

[–] [email protected] 10 points 9 months ago (1 children)
load more comments (1 replies)
[–] SendMePhotos 12 points 9 months ago* (last edited 9 months ago) (4 children)

But like... Correct me if I'm wrong but in my experience tab does not always equal 4 spaces.

E: thanks all. I didn't fully understand.

[–] [email protected] 43 points 9 months ago

That's one of the benefits of using tabs. Some people might like 4 spaces for indentation, whereas others like 2 spaces. If you use tabs, you can configure your editor to use whatever tab size you want, and they're just stored as tab characters in the file.

Tabs for indentation, spaces for alignment (eg for ASCII art).

[–] [email protected] 20 points 9 months ago (1 children)

That's why it's also a big accessibility feature. With big font sizes, four spaces are distracting but you can configure tabs to show up as one character, which is way more reasonable with font sizes larger than usual

[–] [email protected] 8 points 9 months ago

I had a colleague that is legally blind in my second real job. The dude is brilliant (and hilarious) but these things would significantly enable or screw up his productivity. I have always felt fortunate to have had direct butt in seat exposure to the importance of accessibility at such a young age.

[–] [email protected] 9 points 9 months ago

You’re misunderstanding. In this case it means “one tab character” instead of “four space characters”.

load more comments (1 replies)
[–] TootSweet 9 points 9 months ago* (last edited 9 months ago)

'Bout time.

- a Go fan.

[–] thechadwick 9 points 9 months ago (1 children)
load more comments (1 replies)
[–] [email protected] 6 points 9 months ago

Yay at least this comment section has majority tab lovers!

[–] [email protected] 6 points 9 months ago

The enlightened among us use spaces for indentation and tabs for alignment.

load more comments
view more: next ›