this post was submitted on 17 Jun 2023
9 points (100.0% liked)

Programmer Humor

32155 readers
22 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 26 comments
sorted by: hot top controversial new old
[–] Grishaix@feddit.de 2 points 1 year ago (1 children)
[–] OsrsNeedsF2P@lemmy.ml 1 points 1 year ago (1 children)

Imagine not using a minifier

[–] leodude@lemmy.world 1 points 1 year ago

I can imagine that just fine

[–] demonen@lemmy.ml 2 points 1 year ago (1 children)

I use tabs because I prefer 4-space indents and others might prefer 2-space indentation or the gross and unacceptable 6-space indentation.

If more than one person is working on a code base, there will likely be more than one preference, and with tabs everyone gets to just set their own tab width.

Yes, even the 3-space savages.

[–] noisytoot@lemmy.ml 1 points 1 year ago (2 children)

Tabs work fine as long as you don't align stuff. If you do, you have to assume a tab size and mix tabs and spaces.

[–] edward@lemmy.ml 2 points 1 year ago* (last edited 1 year ago)

Generally aligning stuff isn’t nice. But if you do, it’s tabs up to whatever level of indentation you’re at then spaces the rest of the way. So you wouldn’t have to assume a tab size. And the tabs and spaces have different semantic meaning (indent vs alignment) so mixing them makes sense. It's even built into Jetbrains IDEs, where it's called "Smart Tabs".

Although really just adding a level of indent is better than aligning.

[–] gun@lemmy.ml 1 points 1 year ago

This is a legit observation. However, I would argue that spaces needs a set indentation width anyway, so if tabs had a set indentation width that coders are expected to maintain when aligning code, it wouldn't make a difference. Enforcing that in practice may be different, but in theory it works.

[–] aaaantoine@lemmy.world 2 points 1 year ago (1 children)

That's because these programmers are getting paid by the character.

This is also why Java dev pays so well.

[–] ReakDuck@lemmy.ml 1 points 1 year ago (2 children)

System.out.println("Wow, so little amount of characters to print this!");

[–] Grishaix@feddit.de 1 points 1 year ago (1 children)

std::cout << "Wow, so little amount of characters to print this!" << std::endl;

[–] ElectronSoup@kbin.social 0 points 1 year ago

std::puts("Why do so many C++ programmers not use the right tool for the job?");

[–] Eavolution@kbin.social 1 points 1 year ago (1 children)

Or the slightly more readable brainfuck:

++++++++[>++++[>++>+++>+++>+&lt;&lt;&lt;&lt;-]>+>+>->>+[&lt;]&lt;-]>>.>---.+++++++..+++.>>.&lt;-.&lt;.+++.------.--------.>>+.>++.

[–] ReakDuck@lemmy.ml 1 points 1 year ago

Hey! Brainfuck is a fun puzzle language and nothing someone does at a job to do money per character. Would be funny if yes

[–] noisytoot@lemmy.ml 1 points 1 year ago (1 children)

Seven semicolons are the correct way to do indentation (it even alliterates):

int main
(void) {
;;;;;;;printf("like this\n"); }
[–] dystop@lemmy.ml 2 points 1 year ago* (last edited 1 year ago) (1 children)

the correct way is to never indent and never use whitespace. Saves memory.

Your goal should be 1LOC every month, no more.

[–] booty@hexbear.net 1 points 1 year ago

all code should be written in one line with absolutely no breaks. it's the most efficient way

[–] gnuslashdhruv@lemmy.ml 1 points 1 year ago (1 children)

Is this some kind of python meme I'm too C++ to understand?

Now, I'm completely willing to start a war about { going on the next line.

[–] TheInsane42@lemmy.ml 1 points 1 year ago* (last edited 1 year ago)

Totally agree, all my { end up on the next line, 1st spot when starting a function, last character of the keyword when starting an if/for/... section. I even put the closing one on the same line when it's single line, else either at the end of the closing line (when changing really old code) or same indent.

So indenting varies a lot, which makes most 'new' programmers go mental.

while (my code)
    { I'll do it my way }

if (! liked)
 { toughen-up }
else
 { get used to it
   multi-line can go both ways...
 }

That is, unless the font used messes it up. ;)

[–] UpperBroccoli@feddit.de 1 points 1 year ago

[ ] tabs [ ] spaces [x] why would I even care, I press tab and the editor puts either a tab or a number of spaces, couldn't care less...

[–] Lanthanae@lemmy.blahaj.zone 1 points 1 year ago

I'd imagine it's because people who use spaces are either further in their career in average (because the modern programming ecosystem in general uses tabs so new devs are more likely to only know that) or they're just more serious about software development because the kind of person to die on that hill is also the kind of person who is very obsessive about other things as well.

[–] edward@lemmy.ml 0 points 1 year ago* (last edited 1 year ago) (3 children)

Tabs make more sense because that’s exactly what they’re for, indents. Ignoring how it looks, which makes more semantic sense for an indent, or ? You wouldn’t use a bunch of spaces to indent a paragraph, so why would you use it to indent code?

[–] StudioLE@programming.dev 1 points 1 year ago

And by using tabs the IDE can customise whether it's displayed as two character or four character deep indentation. It just makes so much more sense.

It's insane that anyone considered spaces to be a sensible default. Yet I primarily develop in C# where four spaces are the standard so that's what I use. However the reality is the IDE handles all the formatting automatically so I'm never actually typing four spaces

[–] 0x00cl@lemmy.ml 1 points 1 year ago

Well, the tab key was created to avoid repeatedly having to press space to create an indentation, but that was on typewritters, so either way, you can use spaces or tab key to indent text.

Now text editors can transform tab character ('\t') to desired amount of spaces, and I think the problem with using tab characters in code ('\t') is that system may have different configurations for the amount of space a tab char takes, making it look inconsistent on different systems, while space char is pretty much standard on every system.

[–] Vlyn@lemmy.ml 0 points 1 year ago (1 children)

I was pro tabs when I started out with software development. It just made sense, right? You press the key once, you get a single symbol, you have your indention, neat. And there is the argument that everyone can adjust their tab sizes, want it to be 2 spaces? 4? 6? Whatever? Awesome!

Then you write actual code and this perception changes. Tabs make a mess, developers often align both code and comments to make sense. That alignment only works at x-spaces and utterly breaks if you change tab width.

An example in C# with LINQ (just semi-random stuff):

var test = customers.Where(c => c.Deleted == false
                             && c.Enabled
                             && c.HasProducts()
                             && blockedCustomers.Contains(c.Id) == false);

This kind of indention only works with spaces, not with tabs. And no, mixing tabs and spaces doesn't work (like some users claim, that you can indent with tabs and then do alignment with spaces.. nope, if you change tab with then your space alignment breaks).

Honestly, I don't care either way, I just use what my company uses and adapt. But till now it has always been spaces (even though I was team tabs in university) and now I actually prefer spaces as it just makes sense. It's consistent, it's easy, it works everywhere.

Btw. the Lemmy code editor is shit, trying to align this was trial and error for a minute :-/

[–] edward@lemmy.ml 1 points 1 year ago* (last edited 1 year ago)

if you change tab with then your space alignment breaks

No, it doesn't? Here's the exact same text content with different tab widths:

The tabs are smaller but the spaces are the same, so the alignment remains.

[–] Manbart@beehaw.org -1 points 1 year ago

Well, spaces are superior, so…