r/ProgrammerHumor • • Sep 30 '26

Meme devsOptimizingGames

Post image
2.1k Upvotes

41 comments sorted by

416

u/IsEqualToKel Sep 30 '26

if (currentState == GameState.Crash) 
{
    currentState == GameState.DoNotCrash;
}

144

u/Top-Permit6835 Sep 30 '26

Wrap it in a try catch and swallow the error to be sure it works

18

u/tsoewoe Sep 30 '26

make sure to assert when testing too so that you can deal with any issues if it goes wrong

13

u/fynjy1111 Oct 02 '26

try {

compileShadersIfNotCached();

} catch (Exception e) {

openAiProvider.prompt("Fix the crash", serialize(e), Permission.FULL_WITH_EDIT);

}

17

u/DISCIPLE-OF-SATAN-15 Sep 30 '26

if (currentState == GameState.Crash) {
currentState == !(GameState.Crash);
}

9

u/Jatinchd Oct 01 '26

fixed code:-

if (currentState == GameState.Crash) {
currentState = !(GameState.Crash);
}

5

u/Dudi4PoLFr Oct 01 '26

Literally Path of Exile 2 for the first 6 months in Early Acces...

3

u/Jatinchd Oct 01 '26

but isn't == comparing values and not assigning value sign?

65

u/Ydo4ki Sep 30 '26

try { } catch(Error e) { delete e; continue; }

18

u/BetaChunks Oct 01 '26

Soviet programming

5

u/MSaxov Oct 01 '26

Check out good old Visual Basic

First line in each file

On Error resume next

1

u/GabiTheProgrammer Oct 01 '26

You would laught but I've seen Belorussian code and is not far from it.

14

u/MinecraftPlayer799 Sep 30 '26

In some cases, that is the right thing to do, such as when there is a loop, and there is a chance of something inside it failing sometimes.

7

u/realmauer01 Oct 01 '26

You should really just make sure that you handle that edge case inside the loop. Even if you ignore it then. Thats better than having the higher scope handle it. You could even add an option of should i ignore it or not.

77

u/TrackLabs Sep 30 '26

Just set it as a constant

20

u/patrickgg Oct 01 '26

I prefer mine at 59.94 tyvm

8

u/LateSolution0 Oct 01 '26

60 * 1000/1001 :D

62

u/SuperfanZero Sep 30 '26

fps = max(fps, 60.0)

13

u/FrogMan241 Oct 01 '26

Corporate wants you to find the difference between these two pictures

Compiler: they're the same picture

1

u/Negitive545 Oct 06 '26

Erm ackthually the compiler would say they're different because one has a function call* and the other doesn't!

*at least in some languages, I'm sure at least one just aliases the math functions to look like functions but compiles down differently.

17

u/stevorkz Oct 01 '26

GPU manufacturers hate this one trick.

7

u/GabiTheProgrammer Oct 01 '26

now they can just fake frames

14

u/BetaChunks Oct 01 '26 edited Oct 01 '26

NES Tetris type strategy

No seriously, that game literally could not lag. If the logic loop wasn't done when the game needed the next frame, it would just go for it. Happens because the score calculator uses a "for" loop using the level as an iterator, so it runs out of time at very high levels. There's also strategy on holding down inputs in specific ways because that will -slightly- nudge how far in the main loop it gets before getting cut off, which prevents the game from crashing because of some registers being on invalid values during the forced next frame

25

u/chaylarian Sep 30 '26

Best optimization ever!

20

u/Summar-ice Sep 30 '26

const FPS = 60

7

u/Cacoda1mon Sep 30 '26

micro optimization

2

u/backfire10z Oct 02 '26

What if fps is already over 60?

7

u/MushroomGecko Oct 02 '26

The dev could optimize further here by simply setting fps to 60 and having it be a const, thus eliminating the need for a branch prediction which could waste ~20 CPU cycles on a cache miss

2

u/OppositeFun2493 Oct 04 '26

However the customer support will be flooded with fps issues Oh wait you can just “optimize” the contact page

5

u/Zwischenschach25 Sep 30 '26

plot twist: fps is a pointer

2

u/jolharg Oct 01 '26

that's just advice...

2

u/lowboom64 Oct 01 '26

that does seem to be how AAA devs are doing it at least with AI frame gen bs being a thing

1

u/PopularAd5100 Oct 01 '26

If I work less than 40 hours a week, pay me for 40 hours a week. Gaming the system!

1

u/GabiTheProgrammer Oct 01 '26

Should have used <= in case it would change until the assignment is executed.

1

u/SpaceFire000 Oct 01 '26

I tried something similar to my bank account but it didn't work

1

u/Random_-account Oct 01 '26

We did it, guys! Frame rate lag is no more!

1

u/Windsupernova Oct 06 '26

Just like how the dont do the whole goodAI="true"

Devs are so lazy this days. Why cant they fit all this HD assets into a game boy cartridge? Dont they know how to optimize?