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

Programmer Humor

19572 readers
1345 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
 
top 50 comments
sorted by: hot top controversial new old
[–] SzethFriendOfNimi@lemmy.world 214 points 8 months ago* (last edited 8 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@lemmy.world 55 points 8 months ago* (last edited 8 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 )

[–] jadero@programming.dev 10 points 8 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@lemmy.world 7 points 8 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)
[–] kakes@sh.itjust.works 39 points 8 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.

[–] Maestro@kbin.social 27 points 8 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.

[–] LaggyKar@programming.dev 8 points 8 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?

[–] lud@lemm.ee 8 points 8 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)
[–] kureta@lemmy.ml 11 points 8 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.

[–] Traister101@lemmy.today 92 points 8 months ago (13 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.

[–] zea_64@lemmy.blahaj.zone 17 points 8 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 (12 replies)
[–] redcalcium@lemmy.institute 73 points 8 months ago (4 children)

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

[–] mexicancartel@lemmy.dbzer0.com 43 points 8 months ago (1 children)

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

[–] redcalcium@lemmy.institute 12 points 8 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.

[–] mexicancartel@lemmy.dbzer0.com 9 points 8 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@lemmy.world 18 points 8 months ago (2 children)

*three spaces.

Actually, let's make that two.

load more comments (2 replies)
[–] Liz@midwest.social 11 points 8 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@lemmy.world 44 points 8 months ago

Team Tab Supremacy Unite!

[–] Fades@lemmy.world 43 points 8 months ago

Hell yeah tabs

[–] hakunawazo@lemmy.world 42 points 8 months ago (1 children)

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

[–] hansl@lemmy.world 8 points 8 months ago

“He's me.” - Obi Wan Kenobi

[–] Scoopta@programming.dev 41 points 8 months ago

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

[–] aeharding@lemmy.world 34 points 8 months ago (1 children)

Is this real or am I eating the onion

[–] TootSweet@lemmy.world 44 points 8 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@lemmy.world 26 points 8 months ago (1 children)
[–] Deceptichum@sh.itjust.works 32 points 8 months ago* (last edited 8 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.

[–] pcouy@lemmy.pierre-couy.fr 20 points 8 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)
[–] mindbleach@sh.itjust.works 33 points 8 months ago (2 children)

Tabs exist specifically for spacing out stops. They're viewer-configurable, avoiding holy wars about 4 or 8 or that one idiot suggesting 3.

I do not give a shit if your seventeen-argument function has the overflow variables line up exactly with the paren. Just put them one step further in.

[–] mindbleach@sh.itjust.works 13 points 8 months ago (3 children)

I just remembered the dumbest argument I've ever suffered about this - someone insisting the "length" of one tab changed, depending on what's before it. As in, is it eight spaces, or seven? Or six! It only goes up to eight spaces! No. It goes one stop. The same way a newline goes one line, and cannot by measured by how many times you'd slap the spacebar to get text to wrap around to the next line.

load more comments (3 replies)
load more comments (1 replies)
[–] brisk@aussie.zone 21 points 8 months ago (8 children)

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

load more comments (8 replies)
[–] dust_accelerator@discuss.tchncs.de 20 points 8 months ago

Feels relevant

Just make everything Shittier

[–] wesker@lemmy.sdf.org 19 points 8 months ago* (last edited 8 months ago) (1 children)

Maybe it is time for another civil war.

[–] deadbeef79000@lemmy.nz 13 points 8 months ago (1 children)
load more comments (1 replies)
[–] fruitycoder@sh.itjust.works 18 points 8 months ago (3 children)

Spaces are supiror because its easier to text boxes.

I mean where even is the tab on my phone?

[–] Lojcs@lemm.ee 20 points 8 months ago* (last edited 8 months ago)
Right  
	here

Edit: til tabs make code blocks in lemmy

[–] Potatos_are_not_friends@lemmy.world 13 points 8 months ago (2 children)

Another person who codes on their phone.

I bow to your greatness.

[–] mexicancartel@lemmy.dbzer0.com 7 points 8 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)
[–] treechicken@lemmy.world 17 points 8 months ago* (last edited 8 months ago)

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

[–] SendMePhotos@lemmy.world 12 points 8 months ago* (last edited 8 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.

[–] dan@upvote.au 43 points 8 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).

[–] gitamar@feddit.de 20 points 8 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

[–] Waraugh@lemmy.dbzer0.com 8 points 8 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.

[–] KairuByte@lemmy.dbzer0.com 9 points 8 months ago

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

load more comments (1 replies)
[–] thechadwick@lemmy.world 9 points 8 months ago
[–] TootSweet@lemmy.world 9 points 8 months ago* (last edited 8 months ago)

'Bout time.

- a Go fan.

[–] mexicancartel@lemmy.dbzer0.com 8 points 8 months ago

Yay at least this comment section has majority tab lovers!

load more comments
view more: next ›