Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Hacker’s delight (2nd ed.)
Warren H., Addison-Wesley Professional, Upper Saddle River, NJ, 2013. 512 pp. Type: Book (978-0-321842-68-8)
Date Reviewed: Jan 7 2015

Computational speed matters. Programmers and computer science students are taught to carefully select or design an algorithm; to write clear, maintainable code; and to rely on compilers and processors to provide the speed. In most cases, that is the right thing to do. But there are cases when one must go deeper, down to the bit-level and machine-level instruction, to get the most speed possible. This criterion certainly applies to hardware designers, compiler writers, and embedded and other time-critical system software developers. For these folks, this book is a must. For the rest of us, this book can be a source of great fascination and intellectual reward.

Hacker’s delight, more than most books, reflects the experience and idiosyncratic interests of the author. Warren has spent decades looking deeply into the ways and means of number representations, and every possible way to efficiently code basic arithmetic and logic operations. And he has gathered a treasure trove of information in a very readable book. Having all of this material in a single book, rather than scattered in often hard-to-find places, is very useful and convenient.

The book covers the low-level material–manipulating bits and bytes for representing numbers; doing addition, multiplication, and division; detecting overflows; and searching for and counting bits–in the most thorough way possible. Chapter 1, “Introduction,” presents a language- and processor-independent notation–Warren calls it computer algebra–that is the primary means of expressing formulas and algorithms throughout the book. For every expression in this notation, Warren also shows the corresponding C code, and C is indeed used to illustrate several algorithms. In addition, Warren shows two illustrative RISC instruction sets, a basic set and a full RISC set, which are representative of current architectures. Warren mentions these instructions, as well as several current processors, when he wants to let you know, for example, the minimum number of instructions in which a given operation can be expressed.

In addition to what can be done with bit-twiddling at the most basic level, Warren also includes several areas where these techniques can be used to great advantage: finding square and cube roots, unusual elementary number systems, error-correcting codes, gray codes, cyclic redundancy checks, error-correcting codes, computing Hilbert’s curve, and using Willan’s and Wormell’s formulas for finding prime numbers.

In these days of multiple cores, it is advantageous and important that code be what I call “parallelizable”: you want operations to be performed in sequences of independent instructions that can be farmed out to different processors for parallel execution. And, if possible, you want to minimize or avoid loops. Warren also pays attention to that.

All of this material is presented very clearly. While the writing is clear, the subject matter sometimes is not. Understanding and mastering the material in this book requires effort–sometimes significant effort. Warren presents a lot of formulas, but he doesn’t always show their derivation; he presents some theorems, but not always their proofs. Some mathematical background is given, but not always. Warren also includes exercises, some of which are open-ended or hard. Mercifully, he also provides the answers--almost 50 pages of answers, so they are not just hints.

The website for this book, http://hackersdelight.org/, shows the table of contents, the foreword, a sample chapter (chapter 2, “Basics”), errata for the first edition and for the first and second printing of the second edition–very important, as some items are essential for correctness or completeness, downloadable C code, a copy of the superoptimizer “A Hacker’s Assistant,” other related material, and links to related sites.

Clearly, this is an idiosyncratic book; depending on the reader’s background and experience, it can be challenging. But it can also be immensely rewarding. The reward is commensurate with the effort you put into it. For example, when a formula is hard to grasp, it helps to try to derive it, to come up with enough examples to convince yourself that it works, or to translate it into a program, run it, and examine the results. In fact, if you want to sharpen your programming skills, this book is a goldmine of formulas and algorithms you can translate into your favorite language; for good measure, you could look up the generated code and check whether it produces code as efficiently as Warren asserts it is possible to do.

So is this a useful book? Yes, in certain niches. Most readers, though (myself included), will value it more for its austere, tantalizing appeal than for its usefulness.

Hacker’s Delight is bound to become a classic. I recommend it very highly, especially for upper-level undergraduates and graduate students.

More reviews about this item: Amazon, GoodReads

Reviewer:  Edgar R. Chavez Review #: CR143060 (1504-0259)
Bookmark and Share
  Featured Reviewer  
 
Coding Tools and Techniques (D.2.3 )
 
 
Optimization (D.3.4 ... )
 
 
Programming Techniques (D.1 )
 
Would you recommend this review?
yes
no
Other reviews under "Coding Tools and Techniques": Date
Typographic style is more than cosmetic
Oman P., Cook C. Communications of the ACM 33(5): 506-520, 1990. Type: Article
Mar 1 1991
Obfuscated C and other mysteries
Libes D., John Wiley & Sons, Inc., New York, NY, 1993. Type: Book (9780471578055)
Aug 1 1993
Writing solid code
Maguire S., Microsoft Press, Redmond, WA, 1993. Type: Book (9781556155512)
Feb 1 1994
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy