this post was submitted on 28 Mar 2024
323 points (96.3% liked)

Programmer Humor

19817 readers
68 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 2 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 69 points 9 months ago

Self-documenting code, high contrast… Carry on.

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

Probably still better than bool a; bool b; int c;...

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

🤔... I've never liked i and don't use it...not sure why. I keep thinking I should start but alas I just don't.

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

Honestly? Yes, I agree

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

ThisCommentsMakeItSoThatYouHateMeForWritingLikeThisSeriouslyICanNotStopPleaseSendHelp

[–] serpineslair 14 points 9 months ago

Makes it even better that I'm on mobile so the text wrapped half way through a word.

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

I can read that without any issues whatsoever.

But. If. You. Put. Periods. Between. Each. Word. My brain will force a pause between every single one and I can't override it.

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

Forever Ago I Ran A Minecraft Server And 2 Friends Joined And One Typed Everything They Said Like This and the other managed to misspell every single word with more than 2 letters in it. They misspelled the word "the!" According to Sir Capitalizes Every Single Word, its just much easier to type that way, which raised far more questions than answers...

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

Would you like a snake to replace your camel?

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

Careful, Pascal doesn't like it when you call him a camel

[–] [email protected] 4 points 9 months ago* (last edited 9 months ago) (1 children)

I decided to be wrong because the correct joke would be too convoluted. I’ll work on that implementation and then you can inject it at runtime via reflection.

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

Thanks for preparing your comment for my dependency injection! I agree that refactorability of comments is preferable over prematurely optimizing for performance.

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

First it needs to work, then it needs to work well, and finally it may or may not work quickly. Along the way, it should also be humorously weird.

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

Best I can do instead is calling it x.

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

Hey, this must be that self-documenting code I keep hearing about

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

I'm assigning all my PRs to you, buddy, your performance metrics will be over 9000!

[–] [email protected] 18 points 9 months ago* (last edited 9 months ago) (2 children)

This has likely been done intentionally for humour's sake, but take a look at some of the names in Apple's AppKit framework, like https://developer.apple.com/documentation/appkit/nspreviewrepresentingactivityitem

[–] qaz 2 points 9 months ago

That page is giving me a 403

[–] BombOmOm 2 points 9 months ago* (last edited 9 months ago)

I'm still annoyed with how verbose Objective-C is. Just check out what one has to do to create and concatenate a string. Madness:

    NSString * test = [[NSString alloc] initWithString:@"This is a test string."];
    NSString * test2 = [test stringByAppendingString:@" This value is appended."];

And god forbid you want to concatenate two things to a string:

    NSString * test3 = [test1 stringByAppendingString:[test2 stringByAppendingString:@" Adding a third value."]];
[–] [email protected] 16 points 9 months ago (1 children)

Obviously, we can't allow code like that - PascalCase is heresy... camelCase that shit.

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

snake_case gang represent

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

I'd ask what I'm looking at here but feel I might regret it

[–] [email protected] 10 points 9 months ago* (last edited 9 months ago) (2 children)

In Oct’23 a basic Text widget with Subprocess to run shell commands allowed me to take my command line fu into a different arena because Tkinter gave me special tricks. This tool (shell functions) allows me to type up GUI apps or any Python script with less effort, for my fingers and brain.

wc newide; ksh newide | wc

513 1671 11018 newide in pnk

604 1987 29867 newide in python

The blocks of color are capital letters colored using tkinter methods (tag_add & tag_configure) with a bg and fg of the same color to make it look like a lego block, it’s all ASCII. On the right, an idle clicker game/toy made with pnk.lang, also just ASCII/UTF-8. The IDE you see in the pic also was coded using functional shell language I call pnk.lang and the original first iteration of this specification is in the legacy folder in the repo below. Just me learning how to code faster in Python but in shell but in neither at this point.

https://github.com/dislux-hapfyl/pynksh

https://www.reddit.com/r/pnk/

Don’t be put off by Ksh because Bash can also interpret it, since it’s just shell functions that print Python code. But I have plans to use an Xbox controller so I can move away from building with the keyboard at piecemeal rates. I will do this by abstracting away identifiers and all data we use as engineers into “dictionaries” to then transform it into a spatial system. I already done this first step! Using a basic grid with a maximum of 10 rows x 3 cols, indexing row[0-9] col[0-2], as you see there on the left side, and by using a letter I then categorize the functions of pnk(shell+python) so I can have 30 x 26[a-z] available slots; a00 b11 k22 and so on…by making it a visual shortcut that reduces cognitive load and typing for me.

Take a closer look at my repo without dismissing it too quickly. It could seem unnecessary but maybe someone else can see what I have made as useful and how we gonna take it to higher levels of abstraction and create a new realm for making computer applications in an abstract game/IDE of art and code. Perhaps it’s that creator effect that happens when you make something for the first time that makes me see its future utility and appeal. All this was made incrementally using my own software I built from scratch. I do have a great vision and would love to speak to anyone who is interested. I also demonstrate the utility of this small tool on youtube[link in repo]. Thanks.

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

Ok I don't completely get the use case but that's...impressive. Thanks for the detailed explanation and good luck moving it forward

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

Yea this looks productive.

Imagine how useless the LSP suggestions are.

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

My ASDV professor has two moods: He either names variables like this post, Or he names variables pp (for pointer pointer)

[–] robojeb 2 points 9 months ago

Fuck for some reason pp is giving me flashbacks to having to write using Hungarian notation variable names.

[–] [email protected] 10 points 9 months ago* (last edited 9 months ago) (3 children)

I don’t see the benefit of this long naming convention...

It still allow bug to exist... like the fact that, with this code, the player can still play with 0 Hp.

Should have been better to put a "if(health <= 0)" instead of "< 0"

[–] joshfaulkner 2 points 9 months ago (1 children)

I asked this question on this post on a different instance, but would there be issues being that the code compares a float to integer zero "0"?

[–] BombOmOm 2 points 9 months ago* (last edited 9 months ago)

Since the health is a float, yeah, it can create issues. A health of 0.000000001 is greater than zero, but that would almost assuredly be displayed to the user as simply 0, causing player confusion. The easiest solution is to have health and damage always be integers. A less great solution is to use a non-floating point decimal format. If such doesn't exist in your language, you can emulate one by having health and damage both always be integers, but move the decimal point over, say two points, when displaying to the user.

[–] stockRot 2 points 9 months ago (1 children)

It sounds like the only concern you have with code is its bugginess, which is short sights. This is unfortunately better documented code than stuff I've seen in production. Obviously no one should do this, but let's not act like there's no benefit

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

This is getting absurd, variable names have become variable sentences.

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

Variable essays is the future!

[–] testeronious 8 points 9 months ago

Cleanest code by Unclest Bob

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

I approve. All code should be like this

[–] bandwidthcrisis 5 points 9 months ago (1 children)

Leaning to program on 8-bit machines with 8k of RAM means that even today I abbreviate names.

Plus it was accepted wisdom that shorter variable names were faster for the BASIC interpreter.

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

~~variables don't make it to the compiled binary tho, except debug symbols of course if have those enabled (but deploying them to an embeeded system is a terrible idea, they can remain on the host system)~~

oh you mean on not for

load more comments (1 replies)
[–] kuneho 4 points 9 months ago

Visual Basic looks strange nowadays, huh...

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

Comments are for Suckers.

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

Ugh, this makes me want to “slash slash slash.”

[–] RatBin 2 points 9 months ago (1 children)
[–] [email protected] 6 points 9 months ago (1 children)
load more comments (1 replies)
load more comments
view more: next ›