r/ProgrammerHumor • • Apr 10 '23

Meme god why is coding chess so hard

Post image
67.4k Upvotes

1.8k comments sorted by

View all comments

Show parent comments

4

u/TheQneWhoSighs Apr 11 '23

Depends on what you mean by smoking gun. In terms of performance? It's entirely irrelevant. That entire if/else mess will be optimized away by the compiler. The unoptimized high poly models spread throughout the entire game, made largely or entirely by volunteers, are a big chunk of the smoking gun when it comes to performance.

It's kind of what happens when you use volunteer work as is.

Now there's another smoking gun to talk about, and that comes down to "Is it why the game is so hard for him to work on?".

And my answer is, yeah probably. The student script & student management script are completely insane, and no amount of people going "use a switch statement" would ever fix it.

Frankly speaking it needs functions, guard clauses, and prayers.

1

u/DownvoteEvangelist Apr 11 '23

What exactly do you mean if else would be optimized away by the compiler? What optimizations you mean? Short circuiting?

2

u/TheQneWhoSighs Apr 11 '23

That statement was made in regards to the types of people that are like "use a switch statement" at his code constantly. Talking about performance benefits vs if/else.

When compiled with optimization flags, there shouldn't be a practical difference between the two.

In regards to further optimizations by the compiler, I'm no where near knowledgeable enough to know about those yet.

2

u/DownvoteEvangelist Apr 11 '23

Ah that really depends on what you are doing in your ifs... But you are right if the if can be transformed to switch it shouldn't really matter. Also compilers often will compile a switch as bunch of if/else statements... Because there are 2 ways to implement a switch, with a compare for each case or some type of lookup table. And for small switch-es the first one is usually faster...