5 ms·
Donald Knuth wrote 4 textbooks in assembly language with advice about why decrement then jump saves 1 assembly instruction per loop iteration. The fact that ev
by dragontamer 2y ago
Donald Knuth wrote 4 textbooks in assembly language with advice about why decrement then jump saves 1 assembly instruction per loop iteration.
The fact that everyone uses his premature optimization is the root of evil remark is hilarious to me. The level of optimization in Knuths writing makes it evident that upfront efficiency effort is worthwhile. Just don't overdo it.
But don't trust me on that quote. Just open book 3 (chapter 5 and 6, sorting and searching) and go read the tape drive simulations of merge sort yourself. You can't miss the printouts, they're huge.
- zahlman 2y ago"book 3" isn't enough for me to identify the textbook you refer to. Could we have a title, perhaps?
- elpocko 2y agoThis is like asking for the title of the Bible after a psalm was quoted on a forum for religion. It's "The Art of Computer Programming", volume 3 (Sorting and searching) by Donald Knuth. HTH
- zahlman 2y agoThis is Hacker News, not Computer Scientist News. Knuth's work wasn't part of my programming curriculum in an engineering program, either.
- elpocko 2y ago>This is Hacker News, not Computer Scientist News. Or Basic Internet Search News.
- karmakurtisaani 2y agoExcuse me, but we are hackers, not some fancy elitist people who think for themselves and find out things on their own using some modern internet search tools.
- kergonath 2y ago> This is like asking for the title of the Bible after a psalm was quoted on a forum for religion. That is…not a great answer, unless you want to reinforce the meme that CS is a cult. Besides, the context you mention is utterly alien to millions of people. People get born every day, and people learn the basics every day. We should be helping them grow, not gatekeeping. Your second sentence was more than enough.
- glial 2y agoProbably this: https://dl.acm.org/doi/book/10.5555/280635 https://dl.acm.org/doi/book/10.5555/280635
- baronvonsp 2y agoThose sound to me like the very definition of optimizations that are not premature though. His goal was to teach foundational elements of running programs on computers. Loops and sorts are used all over the place and improvements scale with inputs. I see a pretty big difference between solving for a problem you don't yet understand (the way I've always mentally framed "premature optimization") and establishing reasons for implementing primitives in optimal ways.
- winternewt 2y agoIn my experience, the people who say"premature optimization it's the root of sal evil" will say that about any and all optimization until the point where all your customers think your product is a slow piece of garbage.
- stickfigure 2y ago> about any and all optimization that hasn't been measured Fixed that for you.
- galangalalgol 2y agoWhen I want some sw to go faster I do profile it, but I also give at least some thought to avoiding unnecessary copying of data or trig functions in tight loops. I regularly have run into people that say considering performance when selecting a data structure is premature optimization. It usually turns out they don't really want to test or profile and just want to churn through tickets. Anything that gets in the way of that bores them.
- pwdisswordfishz 2y agoNo, broken.
- winternewt 2y agoMeasuring would attract even more protest because not only am I using my experience to choose (likely) more efficient algorithms, I am also spending yet more precious company time to measure its performance.
- m463 2y agoI think it was ok to optimize the decrement then jump before publishing 100k hard copies of the code made from trees. also, great story: https://www.folklore.org/Saving_Lives.html https://www.folklore.org/Saving_Lives.html