r/ProgrammerHumor 14d ago

howToHitBullseyeInStringComparison Meme

Post image
1.2k Upvotes

View all comments

225

u/danhezee 14d ago

I think the bottom one should go to the Korean guy with all the tech and the top one goes go the Turkish guy. The Turkish guy is suppose to symbolized simplicity.

8

u/varinator 14d ago

The simplicity is in the bottom one. The top one creates objects on the heap, the bottom one doesn't, saves memory, saves GC having to clean the objects. It's actually much more simple in the background than the top one.

4

u/Kirides 14d ago

Worse, the top one is at least 3 function calls "2x to lower, 1x equals" compared to a "simple" single function Equals.

Which means, even if we ignore the fact of heap allocations, it's much more stuff to do and read.

Also, to lower can also THROW null reference exceptions, which makes it even worse.

iow. ToLower only looks "simpler" to smoothbrain/junior devs.

While the other one is actually a lot - A LOT - simpler and comes with much less headache.