
Writing efficient programs
by Jon Louis Bentley · first published 1982
24mentions
9recommended by
10HN commenters
2010–2024first – last mentioned
90% recommend10% neutral
Why HN recommends it
Slim, practical guide to performance tuning at every level, from micro-optimizations to program-wide design. Its broad ideas remain useful for working programmers who want to speed up code.
Summarised by Claude from recommending comments
book about writing correct and efficient programs.
Affiliate links. As an Amazon Associate I earn from qualifying purchases.





…programming-in-the-small, though it does talk about some big picture too), also it is old and out of print (last I checked), but I thought it was really good when I bought and read it, so mentioning it: Writing Efficient Programs Also has a great bunch of "war stories" about performance tuning in real-life, including one in which people, IIRC, improve the performance of quicksort on a supercomputer by 1 million times or some…
on “Ask HN: What's the best computer science book you've read recently?” ↗A book by Jon Bentley [1], "Writing Efficient Programs", is very good for this area. It is out of print, probably, was written many years ago, but IMO is still likely to be very useful for a _wide_ range (not all) of performance issues. This is because he…
on “Ask HN: What are the 20% tips that will get my code to performance 80% faster?” ↗…doesn't matter: The C Programming Language, http://en.wikipedia.org/wiki/The_C_Programming_Language The Elements of Programming Style, http://en.wikipedia.org/wiki/The_Elements_of_Programming_Sty... Writing Efficient Programs, http://en.wikipedia.org/wiki/Jon_Bentley Programming Pearls, http://netlib.bell-labs.com/cm/cs/pearls/ The UNIX Programming Environment, http://en.wikipedia.org/wiki/The_UNIX_Programming_Environmen...…
on “Ask HN: Simple exercises for a python beginner?” ↗…Bentley's books are outstanding but don't fall into the quick read category in my opinion. They are complex and need careful study (and working the exercises) to get all you can from them. His 1982 book, Writing Efficient Programs, and the 1981 precursor, Writing Efficient Code, ought to be read by every C programmer. Sadly, they are now out of print and hard to find. Writing Efficient Programs is a breezy tour of the tricks…
on “Which programming book you just couldn’t stop reading from start to end?” ↗In addition to that great list, see also "Hacker's Delight", and several of Jon Bentley's books (Programming Pearls, Writing Efficient Programs, etc.). They're dated, but the basic ideas are eternal. The application to x86 requires combining those ideas with the specifics you get from Agner Fog's references.
on “Minting Money with Monero and CPU Vector Intrinsics” ↗…to say. The Unix Programming Environment, by Kernighan and Pike. Ditto. Programming Pearls, and More Programming Pearls, by Jon Bentley. Among many other things, some clever / advanced uses of awk. Writing Efficient Programs, also by Bentley. I had mentioned it on HN earlier, and someone replied saying they had used it in real life, and it was gold. SQL for Professionals, by authors whose names I forget. The Object Primer,…
on “Ask HN: What are the most eye-opening textbooks you have ever read?” ↗Bentley's book "Writing Efficient Programs" is also really super. Unfortunately, it's been out of print for a long time. If you ever see it, snap it up.
on “Jon Bentley's Programming Pearls: 25 years old, still brilliant” ↗…of at least one person who seems to straddle both those worlds - Jon Bentley: https://en.wikipedia.org/wiki/Jon_Bentley_(computer_scientis... He wrote Programming Pearls, More Programming Pearls, and Writing Efficient Programs. I own copies of either two or all three of those, and have read good amounts of the first two, and pretty close to the whole of the third (some years ago), which is out of print. A fantastic book (the…
on “Computer Science from the Bottom Up (2013)” ↗Jon Bentley, _Writing Efficient Programs_ and Kernighan & Ritchie's _C Programming Language_.
on “Ask HN: What books had the greatest effect on how you structure your code?” ↗…processors' pipelining and suchlike features existed. E.g., it (using a sentinel to avoid one comparison per iteration - the check for passing the array end - in a search) is mentioned in the classic book "Writing Efficient Programs" by Jon Bentley. (great book, BTW. I owned and read most of it.) See Bibliography section here: https://en.wikipedia.org/wiki/Jon_Bentley_(computer_scientis...
on “I Got a Knuth Check for 0x$3.00” ↗>BLISS links from Wikipedia are still working >https://en.wikipedia.org/wiki/BLISS Interesting. I remember Jon Bentley [1] mentions BLISS multiple times in his book Writing Efficient Programs. The book is a gold mine of software performance tuning techniques (with recommendations on when to use them or not), organized in the form of many numbered and well-named "rules" (so that you can remember…
on “Mezzano – An operating system written in Common Lisp” ↗…the ones others have mentioned, e.g. like Soul of a New Machine,the Hackers book by Levy, the 2 Programming Pearls books by Jon Bentley, etc. Bentley also wrote a less-often-mentioned gem of a book: Writing Efficient Programs. It is about performance tuning of programs at many levels, micro to macro.
on “Ask HN: Computer Science/History Books?” ↗…If you are serious about learning how to understand and improve code, this is the book for you. (Full disclosure: Dick is a long-standing friend and one of the brightest and insightful guys around.) Writing Efficient Programs (Prentice-Hall Software Series) 1st Edition by Jon Louis Bentley (https://www.amazon.com/Writing-Efficient-Programs-Prentice-H...) This book is out of print but I believe it's a better read that Jon's…
on “Ask HN: What excellent technical books have you read in 2021?” ↗Also checkout the old (and slim) classic Writing Efficient Programs by Jon Bentley (of Programming Pearls fame).
on “Ask HN: Programming Courses for Experienced Coders?” ↗The book "Writing Efficient Programs", by Jon Bentley, is still a valuable resource. See the short subthread starting with a comment I posted here some years ago: https://news.ycombinator.com/item?id=13407192 A few people had replied,…
on “Ask HN: How can I learn about performance optimization?” ↗