Thursday, April 21, 2011

Premature optimization is the root of all evil

And optimization where it isn't needed, stinks.

While viewing response to someone asking why their code didn't work, someone responded noting "To save yourself some typing, when you have an expression in the form 'a = a-b', you can write it as 'a -= b'. In your code, it would mean that 'health=health-dmg' can be written as 'health-=dmg'."

I'm glad they took the time to respond and educate, but I can't quite help thinking that the idea expressed isn't natural and doesn't result in any real benefit to the compiled program and ultimately hinders understanding. Certainly not for the site where the question was posted, the developer was not experienced and was asking for help.

Do those of you who are experienced understand how this sort of thing puts some people off? Is it that you've forgotten what it is like to be honestly ignorant? Do you think it is really important to be aware of and use that specific expression?

The question was about understanding a concept, not about optimized semantic expression.

Those of gear wisdom please note: "dumbing down" is an intellectual challenge and opportunity for the teacher and mentor - not a reason to be critical of the student.

No comments:

Post a Comment