this post was submitted on 04 Aug 2023
2 points (60.0% liked)

Programming Quotes

323 readers
1 users here now

Every day, one and only one programming quote is posted by the bot.

The core idea behind restricting posting is to encourage discussion. One quote a day is hopefully a good way to do that.

If you want to submit a quote, please use the following Google Form: https://forms.gle/n9g34eSZ7GVA4mFD8

Credits

founded 1 year ago
MODERATORS
 

Premature optimization is the root of all evil.
--Donald Knuth

More info
This post is created by a bot. If you want to contribute to this community, please take a look at the sidebar

top 1 comments
sorted by: hot top controversial new old
[–] aloso 8 points 1 year ago* (last edited 1 year ago)

Unfortunately, this quote is often taken out of context to argue that optimization is not important. Here's the full quote:

Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.

In other words, you should optimize your code after you have profiled your program to find out which sections are most performance-sensitive, and you should use benchmarks to verify that the optimizations you have applied are beneficial.