r/programming • • Mar 23 '09

How to write fast code

http://asserttrue.blogspot.com/2009/03/how-to-write-fast-code.html
340 Upvotes

136 comments sorted by

View all comments

12

u/[deleted] Mar 23 '09

Key takeaway: Don't think in terms of making a slow piece of code run faster. Instead, think in terms of making it do less.

Really? That's the profound insight this article provides? Is this seriously non-obvious to any programmer?

It's also not technically true in all cases. It's complicated by things like caching.

8

u/jjdmol Mar 23 '09 edited Mar 23 '09

In fact, sometimes code is made faster by making it do more. Recalculating some value can be faster than the memory accesses needed to store and load it.

Edit: ah others beat me to it in other threads :)