views:

258

answers:

7

Knuth said: We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil

I’m curious how he came up with 97%. Could someone please share something about this?

UPDATE: The problem is: This sentence is written in a research paper, how come a subjective statement get accepted in such formal document?

+9  A: 

I don't believe it was meant to be taken as an exact number at all. Just "almost all the time."

Jon Skeet
The problem is this statement is written in a research paper. How come the paper accepted with so subjective statement?
nanda
THAT question is not programming related, my friend.
Yuval A
isn't that (part of) what research is? referencing published works, that is.
KevinDTimm
@kevindtimm: no reference is stated in the original paper
nanda
Disclaimer: I havn't read this paper. But I don't see an issue with this, a paper can make claims that aren't a reference to prior work and then work at substantiating them. Why is this an issue?
Matthew Scharley
It's an issue because this 97% is so big that people almost forget to optimize their code in many case. And it's so big that many people just re-stated this sentence every time an optimization question is asked
nanda
Many people *deliberately* don't optimise their code, because it doesn't *need* optimising (isn't a bottleneck) and doing so would either reduce readability or just take time.
Jon Skeet
Research papers aren't always gems of perfection, like Euclid's _Elements_. Content is important in getting papers accepted, but often prestige and popularity are even more-so. That said, questioning of "common wisdom" is always a good thing to do.
Mike Dunlavey
+11  A: 

80% of all statistics are made up on the spot, including this one.

I think you'll find that Jon Skeet has the right idea.

Matthew Scharley
+1, best statistics joke yet (maybe the only one)
Patrick McDonald
+1, yes good joke and by the way statistics are not to be taken precisely anyway ;)
neuro
That's right, the other 15% can only be interpreted, no doubt leading to new and improved ways to abuse common sense.
Matthew Scharley
"How many studies showed that?" - "Eighty-seven". http://www.dilbert.com/strips/comic/2008-05-08
OregonGhost
+6  A: 

I don't believe it was supposed to be taken literally. There are some circumstances and environments in which optimization is paramount (and hence the 97% rather than say, 99%), but for the majority of programmers, writing the majority of software, the majority of the time - optimization should occur only when necessary, and after proper profiling.

Ali Parr
+4  A: 

In answer to this part of the question:

This sentence is written in a research paper, how come a subjective statement get accepted in such formal document?

Research gets published if it satisfies the norms for what is "research" in the relevant discipline. So for example:

  • Experimental Physics and Chemistry requires reproducible results. If the results are not reproducible it is a black mark against the researcher.

  • Medicine requires studies with a statistically significant findings. Double-blind studies with a large sample size are ideal, but such studies are often too expensive, or not possible for ethical reasons.

  • Mathematicians require proofs. And you'd better not slip up.

  • Philosophers like a good argument ... 'nuf said about them I think.

With the possible exception of Mathematics, there is going to be a degree of subjectivity in virtually all research papers. But this does not necessarily make them bad. Subjective statements per se are only a problem if the reader is liable to misinterpret them as objective.

Papers in the disciplines of Computer Science and Software Engineering are particularly prone to a degree of subjectivity. I think this is inevitable, because in many CS/SE fields it is really hard (expensive) to do the experiments that would allow one to make totally objective statements. For example, how can you measure whether premature optimization (rather than something else) has caused a problem? Or more concretely, how can you objectively measure whether a monolithic kernel is better than a microkernel?

Concerning the quote (I assume) from Knuth:

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.

This is subjective, but Knuth is clearly making no pretension of objectivity here. Rather, he is giving some advice in a particularly pithy and memorable way. This is the kind of stuff that makes research papers interesting to read, IMO.

And for the record, Knuth's opinion is shared by 97% of all experienced software developers. (I just made that up :-)

Stephen C
A: 

I think that statement of Knuth's is mainly a case of "argument by prestige". Who's going to debate it?

I was a prof and, believe me, profs get away with a lot of loose assertions, especially in computer science.

My favorite example of where professors have blinders has to do with software performance, where they go on about big-O and tricky compiler optimization while totally missing the industrial phenomenon of gi-normous software and massive inefficiency due to mountainous over-design.

Mike Dunlavey
A: 

This sentence is written in a research paper, how come a subjective statement get accepted in such formal document?

Because research is not only facts, it's also point of view of recognized authorities, backed or not by facts, but also by gut feelings. Remember that Einstein did not believe in Heisenberg uncertainty principle.

Stefano Borini
Einstein believed Heisenberg was right, he just hated the consequences that result from H.'s theory and he spend many years to find a different interpretation.
Aaron Digulla
A: 

I believe the answer from Mike Dunlavey is the closest one. I believe that Knuth get away with this just because he is 'Knuth'. Imagine someone like me saying that statement in a paper. Well... maybe a lot of people will agree with me, but until it's proven theoretically, my paper will not be accepted.

And people shared Knuth's feeling because they know who is Knuth. Imagine that he doesn't know who Knuth is, I can say that the probability of he rejects that statement will be bigger substantially (Stephen: it won't be 97% anymore ;) )

nanda