I’ve just been in New York, and they’ve instituted what I believe to be an absolutely brilliant law: all restaurants have to show the calorific content of the items on the menus. It’s seriously hard to see how you could be against it: it simply provides more information to the consumer.
The interesting thing about this is how I spotted myself responding to it: I saw the calorific content as the price. I paid almost no attention to how much the order would cost (unless you’re on the knife edge, you don’t) but calories: one way or another I’m going to have to pay those off the hard way.
When optimizing code, everything comes with a price. Sure, there are some quick wins where you stare at the code and think “what bonehead wrote that?”. (In my experience, the answer is nearly always “Oh, me”.) After that point, you can trade memory usage for CPU cycles, CPU cycles for IO and all three for time and money. Then there’s the nasty one: speed for flexibility. Some examples of this are parallelism, denormalisation, responsibility combining and ultimately, kernel hacking. In pretty much all of these cases, you’re giving up the ability to change the code fast for the ability to make the code run fast. And that cost isn’t printed on the menu.
What’s worse, 9 times out of 10 your ability to pivot the code is actually its single most important quality. You’ve got to be doing something pretty special and pretty specific to give that up.