this post was submitted on 17 Jul 2023
460 points (97.1% liked)

Programmer Humor

31800 readers
488 users here now

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

Rules:

founded 5 years ago
MODERATORS
 

When your code works, but you don't know how
@programmerhumor

top 19 comments
sorted by: hot top controversial new old
[–] [email protected] 18 points 1 year ago (1 children)

Just containerize the dev environment and ship that to the customer.

[–] [email protected] 16 points 1 year ago (3 children)

Just make sure to add comments like

//Magic, do not touch

To make sure no-one accidentally breaks the spell.

[–] [email protected] 9 points 1 year ago (1 children)
// Do not delete! Yes, it's not used anywhere in the code, but if it is removed
// the application crashes and the error code is useless for debugging.
let f = 'a';
[–] [email protected] 6 points 1 year ago (1 children)

if ( "a" == "a" ) { // i swear i saw this somewhere }

[–] [email protected] 7 points 1 year ago

I once did const theNumber = 4 in a function (and then took a second, actually random, number and compared it to theNumber).

In the comment to the function I actually referenced https://xkcd.com/221/.

[–] [email protected] 5 points 1 year ago

If you even know which line of random bullshit you changed that made it work, that is

[–] [email protected] 2 points 1 year ago

//HERE BE DRAGONS

[–] [email protected] 14 points 1 year ago

I solved one of these once upon a time.

There was a function that wasn't called from anywhere in the project which if deleted caused the whole system to fail in test and (presumably) production at runtime. It turned out to be scripts for a cron job that were only on the servers. I moved them in to the project and thus version control. Mystery solved.

[–] [email protected] 6 points 1 year ago* (last edited 1 year ago) (2 children)

Well you can't call the code generated by chat gpt as YOURS.

[–] UnRelatedBurner 5 points 1 year ago (1 children)

these things happened before chatGPT tho.

I once wrote C code for a hangman game. I took in a character and checked if it's matching with any of the hidden characters. Long story short I did not code what should happen when the user inputs more than 1 character, but during testing I realized that it just analyzes every chracter one by one, and if you input the same characters multiple times it would just ignore it ofc. Making it possible to type a single character, multiple if you wanna be risky. Or the whole word. I liked it better than if it would work on a "guess" basis because it was way more fun, so I kept it that way. Have no idea why it does what it did, but it works.

better example is & and * in Rust. If someone tells me they can get them good the first try, TEACH ME, or they are lying. When it works it judt works don't you dare touch them.

[–] [email protected] 1 points 1 year ago (1 children)

I think you basically made a Wordle version of hangman by accident there, lol.

[–] UnRelatedBurner 1 points 1 year ago

unexpected crossover

[–] [email protected] 1 points 1 year ago

The way I see, if chatgpt can steal our art, then we can steal its science.

[–] [email protected] 5 points 1 year ago (1 children)

I know why it works. Because it was copied from stack overflow..

[–] [email protected] 3 points 1 year ago

@fckreddit
Haha yeah so some other random dude made it work 😄

[–] [email protected] 5 points 1 year ago

The answer is usually that I've pushed to the dev environment but I'm looking at staging.

[–] [email protected] 5 points 1 year ago

Hi there! The links in your response are not clickable for Lemmy users, here are the clickable versions: [email protected]

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago) (1 children)

Going back to the most famous code comment in Unix history You are not expected to understand this.

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

@sin_free_for_00_days or "# The code is documentation enough"

load more comments
view more: next ›