Another common gripe I have with programming questions/answers found on the Internet:
When someone asks a question about performance, like:
"Is X generally faster than Y?"
And inevitably, some smartass comes along and responds:
"Well have you tried it?
Just write a short program to try it, bruh!"
I always want to reach through my screen and strangle that second person.
Writing meaningful performance unit-benchmarks is
hard!
It's its own art form, that most developers are
not proficient in. (I know I'm not.)
You can easily fall into the trap of writing a benchmark where the work you think you're measuring gets optimized out by the compiler, so you're measuring a null-op.
Or otherwise interacts with the optimizer differently than it would in the context of real-life code.
Or becomes noise compared to the overhead of the benchmark boilerplate you added.
Or behaves differently under your test input data than with realistic data.
And even if the newbie question asker were to somehow avoid all the pitfalls and write benchmarks for X and Y that are meaningfully comparable to each other
and transferable to real-life usage patterns, they'd just still run them on their developer machine and thus have
one data-point.
Or even if they managed to test many hardware/OS combinations, they'd still not understand
why the performance difference (or lack thereof) manifests, and thus cannot learn from it.
There is much valuable experience behind a proper answers like:
"Algorithm X has logarithmic complexity and Y quadratic, so for sufficiently large inputs, X must be faster. But Y avoids [constant overhead] and has an extremely cache-friendly memory access pattern, and thus will be faster on modern machines for inputs sizes of up to at least a few thousand, except under [unfavorable conditions]."
or
"Expression X can be compiled into a single fast instruction on x64 CPUs provided that [conditions] are met, and all modern compilers except MSVC tend to successfully do that - whereas expression Y cannot because [reasons] and is thus slower under those conditions."
I respect that kind of shit a lot.
But there's always one midwit who thinks they're helping™ by being the first to answer the question with a
"Hurr Durr just quickly try it out and see which one is faster!"
I don't resent them for not knowing the proper answer (I often don't);
I resent them for not being able to imagine that the proper answer
exists.