Submitted without comment:
xkcd: Optimization
What can this strange device be?
When I touch it, it gives forth a sound
It's got wires that vibrate and give music
What can this thing be that I found?
It's funny. I've been preparing for a few days a post in here about the relationship between green code and premature optimization. Juts being lazy about it and taking my time to finish.
This XKCD however reminds me of something else: We all are guilty of premature optimization to one extent or another. I find it funny that even on languages like Python which are specifically designed to put explicit, flat and simple code above other considerations, you go to a python group and all people want to ask is how much faster a map function is over list comprehension when function calls are involved. Or how people compete for performance on Project Euler solutions.
Reminds me... you know the amount of times you have heard, or said so yourself, that stateful global variables are bad? Millions of times, spread maybe around a couple of hundreds different people. Me too. And him over there too. And her. Everyone in fact. Everyone always hears that advice by everyone else. You would think that no one in the world uses stateful global variables and everyone is just making sure it stays that way...
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
Well, maybe it is a bit of a mixed message since one of the first things C++ beginners learn is the stateful global variable named std::cout, and then one of the first things C beginners learn is to use printf, which is equivalent to a form of fprintf with the stateful global variable (or rather expression amounting to a global variable) stdout...Originally Posted by Mario F.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I like to be positive and assume that people eventually understand global variables need to be justified, instead of just never used. After all, people seem to prefer global variables to singletons. The more people understand about scope, the less likely they are to abuse it.