this post was submitted on 15 Jul 2025
198 points (95.0% liked)

Programmer Humor

25009 readers
1503 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 42 comments
sorted by: hot top controversial new old
[–] tux0r@feddit.org 3 points 7 hours ago

Then again, Duff’s Device works rather similarly.

[–] sus@programming.dev 47 points 21 hours ago* (last edited 21 hours ago) (2 children)

After working at blizzard for 51 years, I finally found an elegant solution by using the power of recursion

private bool IsEven(int number){
  if (number > 1) return IsEven(number - 2);
  if (number == 0) return true;
  if (number == 1) return false;
}
[–] elvith@feddit.org 21 points 20 hours ago
assert IsEven(-2);
[–] Ebber@lemmings.world 7 points 19 hours ago (1 children)

I removed the tail recursion for you:

private book IsEven(int number) {
    if(number > 1) return IsEven(number - 2) == true;
    if(number == 0) return true; 
    if(number == 2) return false;
}
[–] ulterno@programming.dev 1 points 18 hours ago (1 children)

I didn't get this.

Why return book? Does that have some Blizzard reference?
And why would number == 2return false? This is a function for getting true when the number is even, right?

[–] Ebber@lemmings.world 9 points 18 hours ago* (last edited 18 hours ago)

Haha, you're right. I've now learned two things:

  1. I should not write code on a mobile
  2. I should not become a proof reader

At the end of the day i just wanted the function to be worse, by causing stack overflows

[–] Typewar 5 points 13 hours ago

Lol the amount of bullying this guy is getting lately. I've seen similar spins and bends that looks somewhat legit, making people believe he suck at coding

[–] RonSijm@programming.dev 71 points 23 hours ago (1 children)

You don't get it. This was made in GameMaker Studio 1.4, which doesn't support a modulo operator. You know nothing about this specific framework. I have 8 years of experience and hacked governments. There's no reason to update it now, because it runs on a smart fridge at maximum capacity.

[–] magic_lobster_party@fedia.io 34 points 22 hours ago (1 children)

I worked at Blizzard. I worked at Blizzard. I worked at Blizzard.

[–] Lemminary@lemmy.world 4 points 2 hours ago (1 children)

Yeah, but did your dad work at Blizzard??

[–] magic_lobster_party@fedia.io 4 points 58 minutes ago

I’m the first ever second generation Blizzard employee!

[–] kubica@fedia.io 71 points 1 day ago (3 children)

You could save about half the code by only listing one boolean value and having the other as a default return at the bottom.

Sometimes my genius is almost frightening.

[–] prime_number_314159@lemmy.world 1 points 2 hours ago

If small numbers are much more frequent, it's better to return early. Really, you should gather statistics about the numbers the function is called with, and put the most frequent ones at the top.

[–] LeFrog@discuss.tchncs.de 13 points 23 hours ago* (last edited 23 hours ago)

This noob even forgot zero

But this way your buddy in QA can build extra test cases and pay you back when he wins an award for most test cases created or some other corporate nonsense.

[–] magic_lobster_party@fedia.io 17 points 22 hours ago (1 children)

At least this madness is isolated to this function. It can easily be fixed.

Pirate’s code is just cluttered with magic numbers everywhere. Hard coded numbers that are referring to a big ”story array”, or characters. It’s just a giant web of complexity. The only fix is to start from scratch.

[–] Lemminary@lemmy.world 1 points 2 hours ago

It's simple. The only problem is that your code sucks!

[–] GrilledCheese@lemmy.blahaj.zone 17 points 1 day ago (2 children)

This isn’t his actual code, right? Like this specific code pictured here? I’m aware of the “drama” surrounding him currently.

[–] HornedMeatBeast@lemmy.world 51 points 1 day ago (2 children)

Nah.

Someone added him to an existing meme.

But, if this was his code he would defend it and condescendingly tell you that he is correct, you are not knowledgeable enough to understand and let you know he worked at Blizzard for seven years.

[–] MossyFeathers@pawb.social 22 points 23 hours ago

Did you know that he worked for Blizzard for seven years? Not only that, but he was Blizzard's first second-generation employee. He grew up in Blizzard. An extreme accomplishment to be certain. Thank you based and blizzpilled Pirate Software.

I wonder if he was the one stealing the breast milk. After all, I've heard he can be really childish.

[–] ieatpwns@lemmy.world 7 points 23 hours ago

Second gen blizzard employee

[–] lime@feddit.nu 13 points 21 hours ago

this is an old meme about yanderedev

[–] flamingos@feddit.uk 14 points 1 day ago

Inaccurate, it should be return 1 and return 0 for the true 20 years at Blizzard quality.

[–] themoonisacheese@sh.itjust.works 7 points 22 hours ago (1 children)
[–] Lemminary@lemmy.world 1 points 2 hours ago
[–] _cnt0@sh.itjust.works 3 points 18 hours ago (1 children)

Not to take from all the funny answers ... but

bool IsEven(int i) => (i & 1) != 1;

(C#)

[–] _cnt0@sh.itjust.works 2 points 17 hours ago (1 children)

Though, obviously I had to come up with some ridiculous solutions:

bool IsEven(int i) => ((Func<string, bool>)(s => s[^1] == 48))($"{i:B}");

This one works without conditionals :)

bool IsEven(int i)
{
    try
    {
        int _ = (i & 1) / (i & 1);
    }
    catch (Exception)
    {
        return true;
    }

    return false;
}
[–] Lemminary@lemmy.world 1 points 2 hours ago

s[^1]

Ohh wow, I've been learning it casually for years, and I didn't know that existed in C#. I guess I should go back and hit the books some more.

[–] dejected_warp_core@lemmy.world 6 points 22 hours ago

The fact that this probably doesn't even optimize to a lookup table just gives me pain.

[–] xxce2AAb@feddit.dk 8 points 1 day ago (2 children)

Pah, mathematicians and their generally applicable pure approach to solutions and fancy modulus operations, who needs 'em? Computing is applied and we always work with well-defined finite precision. Granted, writing the boilerplate for all possible 64 bit integers is a bit laborious, but we're programmers! That's what code generation is for.

[–] jubilationtcornpone@sh.itjust.works 2 points 3 hours ago (1 children)

Granted, writing the boilerplate for all possible 64 bit integers is a bit laborious,

I've been trying to figure out roughly how many lines of code that would equal out to but I've run out of fingers.

[–] xxce2AAb@feddit.dk 1 points 1 hour ago

Ah, common issue. When that happens, you just start using your toes.

[–] koper@feddit.nl 3 points 1 day ago

If it works it works. You mathematicians just don't understand the pragmatics. What is tech debt?

[–] kolorafa@lemmy.world 7 points 1 day ago (3 children)

Better/fastest approch would be to check the last bit of the int and return the result. Second use modulo.

This? Dev should burn in hell. Who created this?

[–] cows_are_underrated@feddit.org 6 points 22 hours ago

Alternatively you can divide by 2, turn it into an int, mtiply it by 2 and check if both numbers are the same.

[–] TheFogan@programming.dev 4 points 20 hours ago* (last edited 19 hours ago)

or another stupid, but viable way to do it,

if number = 0:

return true

runloop = true

while runloop:

if number > 0:

number -= 2

else:

number += 2

if number = 1:

return false

runloop = false

if number = 2:

return true

runloop = false

still very shitty amature coding, doesn't depend on modulos, or anything that I can think of that some languages might lack an equivelant of.

[–] chuckleslord@lemmy.world 3 points 23 hours ago

Yandere Simulator Dev. Spaghetti code throughout

[–] harbard@fedia.io 6 points 23 hours ago (1 children)

I pretty much did this at my first coding job lol I was building an online menu that you flip through with the keys lol

I did his "optimized" shading trick for a game my friends and I built for a coding project in school.

Because the project was due in three hours and we realized that we didn't have any menus. So it was a matter of getting anything functional as menus(stage selection, button mapping, main menu.)
So the game itself capped at 60fps on the potato school computers, but the static menus only got 20fps.

[–] webghost0101@sopuli.xyz 4 points 23 hours ago

Definitely a vibe.

Try coding chess next time

See ya in a few years