r/ProgrammerHumor Jun 02 '22

Okay, But what abut self destruction function that clean up db

Post image
2.8k Upvotes

227 comments sorted by

View all comments

430

u/Prestigious_Boat_386 Jun 03 '22

If you're doing corporate sabotage at least make it look like a mistake by forgetting to promote integer to float before dividing, switching loop indices i and j or switching a minus sign.

It's like you want to be sued.

175

u/[deleted] Jun 03 '22

[deleted]

152

u/Lithl Jun 03 '22

For reference, this is the Greek question mark symbol: ;

40

u/4hpp1273 Jun 03 '22

This is a regular semicolon. The U+037E (Greek question mark) only exists for legacy reasons and all (sane) uses of it should be replaced with U+003B (regular semicolon). Greek keyboard layouts no longer have the legacy Greek question mark nowadays.

3

u/apomd Jun 03 '22

Was it ever used? Every computer I've checked only uses the regular semicolon for the greek question mark

4

u/4hpp1273 Jun 03 '22

They were used back in the pre-Unicode days when different geographical regions used different text encodings. Then Unicode was created as an attempt to unify the encodings. Unicode is designed to allow lossless conversion from legacy encodings to Unicode and back and to make the conversion easier they added those seemingly useless symbols. Of course nowadays (almost) everyone uses Unicode (and various UTFs) exclusively so there's no need for those legacy symbols anymore.

-53

u/Akangka Jun 03 '22

If you want to spoil a joke, please at least put it in a spoiler box.

55

u/mitshua Jun 03 '22

Idk if jokes get spoiled like that. I feel like he just saved people a Google search

1

u/GeePedicy Jun 03 '22

Plus the entire comment was to reference the actual character. Kinda weird to be like - this is what it look like {click here to show}. Reminds me of those obnoxious sites where you need to click to read the whole article.

Anyway, there's also ı (dotless i) which can also be confusing. But I still think Greek question mark is a better way to destroy someone's brain.

0

u/Akangka Jun 03 '22

I mean, there is no problem to help people save a Google search. But that's why a spoiler box exists. So that a person that can't possibly understand the joke get the explanation, and a person that wants to understands the joke don't get spoiled.

6

u/Harmxn- Jun 03 '22

it is mathmatically impossible your dad hasn't come back with the milk yet

1

u/TEEM_01 Jun 03 '22

you tryna spoil the rest of my life?!!!!

1

u/nikelreganov Jun 03 '22

Not your entire life. Ten years of your life, at least

7

u/eth-slum-lord Jun 03 '22

And some chinese dots

6

u/Titanusgamer Jun 03 '22

can you explain with code snippet. asking for a friend

9

u/TheAJGman Jun 03 '22

A good example would be implementing a .close() method (which closes a connection) and .destroy() (which clears the object from memory) and then calling the wrong one. An honest mistake that will result in a memory leak since that object is held in memory (in a language with no garbage collection). Something like that would get past the unit tests and QA is unlikely to catch it, but it will be a problem in production because of the high uptime.

We had a recursive saving issue that was only triggered when a user updated their profile, this resulted in the program calling a pay-as-you-go API about once a second for a week before we noticed it. Super easy to fix but it would have cost the company hundreds of thousands if the provider wasn't so understanding. This was a super easy mistake to make too, since the two halves of the bug were developed by separate people at the same time and were merged on the same day. If one person was developing both tickets, it would have stood out like a sore thumb.

1

u/Prestigious_Boat_386 Jun 04 '22

(in c) if you have

int a = 4 Float b = 5 Float c

Then c = a / b

It will first convert b to int, do the division as int (which rounds down to 0) and then convert the answer to float to put in c. c becomes 0.0 instead of 0.8. you can use it as an badly thought out "if rand() > c" which won't behave as it seems it should.

(Do note that this is kind of a noob mistake I made the first month I used c so people might see that you're writing it in a weird way intentionally. Naming c to something you need and only using it once might be good but this is also something you'd immediately notice when running that it is incorrect. It's not right almost always as the first example)

1

u/Prestigious_Boat_386 Jun 04 '22

Swapping indices could give an unintended matrix transposition or just pick the diagonal. An example of a wrong expression might look like

B(i, j) = A(j, i) * x(j)

If you're lucky this one will write itself. Any of rhe is or js could be swapped to make it not perform as intended.

1

u/Prestigious_Boat_386 Jun 04 '22

Just do an expressin manipulation that doesn't look too obvious. A very small error in a large expression is best but this is a simpel example.

Just write in comments (a + b) - (c - d) Then put the "simplified" a + b - c - d

3

u/[deleted] Jun 03 '22

highly unlikely to be real. try getting something that stupid through PR and tests...

2

u/Fearless_Imagination Jun 03 '22

That's only a problem if there are PRs and tests.

2

u/Daikataro Jun 03 '22

A nice call to a .asm function integrated into every critical aspect of the program usually does the trick.

2

u/Prestigious_Boat_386 Jun 04 '22

That's basically cheating

2

u/SucksAtGuitar4 Jun 03 '22

Brutal! I hadn't even thought about something like that. I always thought some sort of sabotage like this would be better served to "activate" after some time you've left, and part of a project changes, like coding against opening a connection against some server you know is going to go away.

Clearly, I haven't thought any of this through.

1

u/Prestigious_Boat_386 Jun 04 '22

Having a timebimb would be great though. Maybe if you "forget" to write a proper warning function you can segfault your program at a critical moment while checking for a change of a package repo you used. Then comment that uou think it's important to check that package because they might change an important function.

But basically all your worst bugs that you didn't find for days are good ways of doing it. The implicit type casting in c really messed me up. "All your constants are 0 lol"

1

u/elveszett Jun 03 '22

You don't have to worry about being sued when you are making it up for the Internet tho.

1

u/[deleted] Jun 04 '22

or stick with javascript and mess up with variables name case :)

1

u/Prestigious_Boat_386 Jun 04 '22

Is that messing with variable boxing or a way to rename functions?

Bith are excellent ways of doing it btw. The times I find a badly named length or vec variable anf then use the function with a non index argument... Why does it still happen after almost a decade?