Comment by xg15

3 days ago

Meanwhile on every programmer's 101 forum: "Space is cheap! Premature optimization is the root of all evil! Dev time > runtime!"

Exactly. Yes I understand the meaning behind it, but the line gets drummed into developers everywhere, the subtleties and real meaning are lost, and every optimisation- or efficiency-related question on Stack Overflow is met with cries of "You're doing it wrong! Don't ever think about optimising unless you're certain you have a problem!" This habit of pushing it to extremes, inevitably leads to devs not even thinking about making their software efficient. Especially when they develop on high-end hardware and don't test on anything slower.

Perhaps a classic case where a guideline, intended to help, ends up causing ill effects by being religiously stuck to at all times, instead of fully understanding its meaning and when to use it.

A simple example comes to mind, of a time I was talking to a junior developer who thought nothing of putting his SQL query inside a loop. He argued it didn't matter because he couldn't see how it would make any difference in that (admittedly simple) case, to run many queries instead of one. To me, it betrays a manner of thinking. It would never have occurred to me to write it the slower way, because the faster way is no more difficult or time-consuming to write. But no, they'll just point to the mantra of "premature optimisation" and keep doing it the slow way, including all the cases where it unequivocally does make a difference.