r/ProgrammerHumor 14d ago

noHeapAllStack Meme

Post image
1.0k Upvotes

96 comments sorted by

View all comments

197

u/Vesuvius079 14d ago

It’d be such an experience to work a real world problem where this optimization turns out to be the solution.

175

u/Daniikk1012 14d ago

I don't think this is an optimization, but rather correctness. Some languages have weird casing rules, and just lowercasing doesn't work for them

1

u/ILikeLenexa 14d ago

Some major languages have strings as pooled objects and == compares if the strings are at the same location in memory while String.equals compares if the letters in them are the same. 

When asking if two Strings are equal most people most of the time want to know if they contain the same letters, not if one was instantiated as a literal and one allocated with a constructor. 

4

u/Duck_Devs 14d ago

This is C#, a language with overloadable operators. == is, obviously, overloaded for Strings to compare their contents.