Programmimg pearls
Jon Louis Bentley · Communications of the ACM · 1985
programming pearls BUMPER-STICKER COMPUTER SCIENCE Every now and then, programmers have to convert units of time.If a program processes 100 records per second, for instance, how long will it take to process one million records?Dividing shows that the task takes 10,000 seconds, and there are 3600 seconds per hour, so the answer is about three hours.But how many seconds are there in a year?If I tell you there are 3.155 X 107, you won't even try to remember it.On the other hand, who could forget that, to within half a percent, rule is usually the person who sent me the rule, even if they in fact attributed it to their Cousin Ralph (sorry, Ralph).In a few cases 1 have listed an earlier reference, together with the author's current affiliation (to the best of my knowledge].I'm sure that 1 have slighted many people by denying them proper attribution, and to them I offer the condolence that Plagiarism is the sincerest form of flattery.Anon.?r seconds is a nanocentury. Tom DuffBell Labs Without further ado, here's the advice, grouped into a few major categories.So if your program takes lo7 seconds, be prepared to wait four months. CodingFebruary's column solicited bumper-sticker-sized advice on computing.Some of the contributions aren't debatable: Duff's rule is a memorable statement of a handy constant.This rule about a program testing method (regression tests save old inputs and outputs to make sure the new outputs are the same) contains a number that isn't as ironclad.When in doubt, use brute force. Ken Thompson Bell LabsAvoid arc-sine and arc-cosine functions-you can usually do better by applying a trig identity or computing a vector dot-product.