Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Optimize for readability. Optimize for maintainance. Optimize for consistency. Once those three are done, you can optimize for performance.


But, you can also possibly habitually change a few things in your initial coding syntax that produces less computational effort to begin with....

I thought it was a good article.


1) We don't know which one takes more computational effort, hence the need for realistic benchmarks with decent confidence intervals.

2) If benchmarks show one style to be slightly faster than another, then I will take note. I've already noted that these benchmarks have no associated statistical information; they're just numbers quoted to an arbitrary precision.

3) If I ever find myself needing such slight increases in speed, it's probably a sign that there's a looming disaster, since it means that a) there's a bottleneck in the program, b) I can't improve the algorithm, c) porting that section to native code hasn't been enough.

If it's a case of death by a thousand papercuts, where slight slow-downs throughout an application are actually making it unusable, then I'll roll up my sleeves and patch the interpreter/compiler (this is easier in self-hosting languages, but doable in all).


No need to get all carried away talking about rewriting compilers or pulling out statistical confidence intervals...

If a certain style has a slight performance improvement, and this can be manifested, and that style is equally as readable and maintainable, there is simply no reason not to adopt it as habit. That's all I'm saying.


If those few things do not break redability, maintaince, consistence, or correctness, why not?

So, first you get good enough on the language to know you are not breaking those. Then you don't adopt micro-optimizations because you are already good enough on it to know what they'll break.


Why? Because most of the ones they show is that a global lookup is more costly than a local one.

Something that may -very- well change quickly. dict() slower than {}, and so on...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: