this post was submitted on 07 May 2024
624 points (97.6% liked)

Programmer Humor

19486 readers
178 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
(page 2) 50 comments
sorted by: hot top controversial new old
[–] [email protected] 16 points 6 months ago

How to write spaghetti code:

[–] [email protected] 27 points 6 months ago (6 children)

Then you realize your code is undebuggable because half the functions and variables have single-letter names or called foo, bar, baz, etc.

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

Since a lot of the english words i know i learned from minecraft, in a farming simulator i named tilled soil"hoed"

I had multiple variables like int isHoed

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

An important professor constantly and frustratingly said

we can call this variable whatever we want, so we’ll call it Fred

Made me panic and irate and focus on the wrong part of the problem. Every. Single. Time.

[–] [email protected] 30 points 6 months ago (1 children)

Gotten even easier after X became a registered trademark. Now the only choice we have left is i. Or ii if you need more variables

[–] [email protected] 20 points 6 months ago (5 children)

"j" is what you're supposed to use if you need another index variable after using "i".

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

installing operating system: 15 minutes, give or take.

give a name to the computer: 45 minutes

[–] [email protected] 16 points 6 months ago (1 children)

I've got that shit on lockdown man.
I name all my devices "Fuck0ff" followed by a 3 letter descriptor of what it is. E.g. - my windows install is Fuck0ffDTW for Desktop Windows, my Garuda install is Fuck0ffDTG for Desktop Garuda(it's a flavour of Arch, btw)

[–] [email protected] 8 points 6 months ago* (last edited 6 months ago) (1 children)

What if you would have 2 devices of same type with same OS or just with OS that starts with same letter? Will you use numbers, if yes, how much leading zeroes if any you will use? If you don't use numbers, will you add a room name? But what if there are 2 devices with same OS in the same room?

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

Luckily I'm not responsible for naming my wife's devices, otherwise the whole scheme would be up shit creak. As it stands I have a dual-boot desktop, a daily laptop, a surface pro4, and an old laptop running Ubuntu server for various self hosted stuff. I've managed to just use 3 letters, I assume as I amass more tech I'll need to start adding numbers, if I have to label for rooms I'll have more than a data hording problem.

[–] [email protected] 23 points 6 months ago (1 children)

There are only two hard things in computer science: cache invalidation and naming things.

[–] [email protected] 37 points 6 months ago (2 children)
[–] [email protected] 3 points 6 months ago

And DNS issues

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

Older C compilers would truncate a variable name if it was too long, so VeryLongGlobalConstantInsideALibraryInSeconds might accidentally collide with VeryLongGlobalConstantInsideALibraryInMinutes.

Legend says that they used to do it after a single letter with Dennis declaring "26 variables ought to be enough for anyone".

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

I had this problem in my job as a drafter. I was wondering why the hell Tekla would complain about the same object name already being in use despite everything having its own name. took me way too long to realize there wad some stupidly max name length and the program did nothing to alarm the user about trying to put too long name. it just cut the overflow away.

[–] [email protected] 3 points 6 months ago* (last edited 6 months ago)

^- triggered

[–] [email protected] 27 points 6 months ago (3 children)

Single character variable names are my pet peeve. I even name iterator variables a real word instead of “i” now.. (although writing the OG low level for loops is kinda rare for me now)

Naming things “x”.. shudder. Well, the entire world is getting to see how that idea transpires hahah

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

X, y, and z should only be used when working with things with dimensions larger than 1. Indexing into a 2D array, x and y are great uses. I'm also totally fine with i and j for indexer/iterator when appropriate, but I hate when people try to make short variable names for no good reason. We have auto-complete just about everywhere now. Make the names descriptive. There's literally no reason not to.

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

I hate short variable names in general too, but am okay with them for iterators where i and j represent only indices, and when x/y/z represent coordinates (like a for loop going over x coordinates). In most cases I actually prefer this since it keeps me from having to think about whether I'm looking at an integer iterator or object/dictionary iterator loop, as long as the loop remains short. When it gets to be ridiculous in size, even i and j are annoying. Any other short names are a no go for me though. And my god, the abbreviations... Those are the worst.

[–] [email protected] 7 points 6 months ago (2 children)

That’s very reasonable, I can get behind that. (my stance is a partly irrational overreaction and I’m totally aware of it lol)

Abbreviations are definitely annoying. My least favourite thing to do with them is “Hungarian notation”. It’s like.. in a statically typed context it’s useless, and in a dynamically typed context it’s like.. kind of a sign you need to refactor

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

Hungarian notation makes sense in a dynamically typed usage (which I despise, but this essentially makes them notationally typed at least) or where you're editor/IDE is so simple it can't give you more information, which I can't see ever being the case in the modern day.

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

Was just talking about gaming genre names being kinda lame (roguelike? Souls-like? Where's the originality?!) and this just furthers my point as programming and video games are intrinsically linked.

[–] [email protected] 18 points 6 months ago (2 children)

floats, doubles, etc are decimallikes. object-oriented programming languages are c++likes. a string that is just the word “false” is a boollike. any language easier to learn than c++ is a pythonlike. any language harder to learn than c++ is a asmlike. don’t like it? then you’re a naglike. you don’t want to be known as a naglike, do you?

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

Javascript is all about them boollikes (or as we sometimes call them, booleish).

load more comments (1 replies)
[–] [email protected] 41 points 6 months ago* (last edited 6 months ago) (1 children)

FullSentenceExplainingExactlyWhatItDoes(GiveThisVariable, SoItCanWork)

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

Just be careful naming your function "stdout()" or things could get weird...

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

Or Fortran variables that collide with Fortran built-in functions.

Keep in mind that array subscript and function call are both () in Fortran.

load more comments
view more: ‹ prev next ›