Jump to ratings and reviews
Rate this book

Hacker's Delight

Rate this book
This book is for anyone who wants to create efficient code. Hacker's Delight will help you learn to program at a higher level - well beyond what is generally taught in schools and training courses - and will advance you substantially further than is possible through ordinary self-study alone.

306 pages, Hardcover

First published July 27, 2002

Loading interface...
Loading interface...

About the author

Henry S. Warren Jr.

2 books15 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
547 (48%)
4 stars
340 (30%)
3 stars
173 (15%)
2 stars
41 (3%)
1 star
24 (2%)
Displaying 1 - 24 of 24 reviews
Profile Image for Ushan.
801 reviews72 followers
May 10, 2016
Imagine a minicomputer programmer in 1972 or a microcomputer programmer in 1982 who needed to implement more integer operations than the standard plus, minus, bitwise and, or and xor provided by the computer's architecture: things like the number of one bits in a word, the position of the rightmost one bit in a word, cyclic redundancy check, the difference between two integers or zero if it is negative, and so on. It is possible to write straightforward algorithms implementing these operations, but it is also possible to do it by combining bitwise logical and arithmetic operations in a clever trick. This book is a chock full of such tricks. The problem is that by 2012, none of it made sense. First, silicon is so cheap nowadays that many of these operations are implemented in hardware in commodity processors: Intel architecture processors have had an instruction for the position of the rightmost one bit in a word since the 80386; ARM processors have had it since version 5 of their architecture. Second, modern processors are superscalar: they execute multiple instructions at the same time unless there are data dependencies between the instructions; in order to compare the performance of a straightforward algorithm with that of a tricky one, one has to look at these dependencies, which the book doesn't. Third, since the 1990s, many commodity processors have had a vector instruction set: MMX and SSEx in the Intel architecture, AltiVec in the Power architecture, and so on; one would think that if the goal is to speed things up, one would look at them, but they do not merit a mention in this book. So one should look at this book as being not so much a practical computer science book as a microprocessor-punk novel.
Profile Image for Brian.
649 reviews283 followers
August 22, 2011
(4.0) Full on geek out, probably only helpful if you're writing assembly or compilers or something

I've not often (if ever?) read a book straight through in one setting, but that happened to me last night (to my wife's great disapproval). It's a tour of clever ways to accomplish all sorts of computation as efficiently as possible (primarily by avoiding any branch statements, the vermin!). I'm not sure I'll ever apply any of these, but I did enjoy the clever mathiness of a state machine implemented without branches.

And then we went to real nerd-town with considering binary representations of numbers using -2 or even -1 + i as the base. No sign bit! No two ints to represent a single complex number!

So this was entertaining, I'll probably never need any of these tricks, but if I do, I know exactly where to turn. :)
Profile Image for Koen Crolla.
771 reviews206 followers
January 11, 2013
Basically HAKMEM repeated by someone worse at mathematics. If you enjoyed this you'll probably like the earlier chapters, though you shouldn't be allowed to read them. If you like numbers, you'll probably like the later ones, though not if you also like any sort of rigour in your maths.
It's unlikely that you won't find anything at all to like in the book (I liked the chapter on Gray codes, for instance), but even if you like it all, you won't find its three hundred or so pages to be $59.99 ($71.99 Canadian) worth of good. If you can get it second-hand, though, consider picking it up; it feels like a book you should own second-hand.
Profile Image for Nick Black.
Author 2 books820 followers
December 11, 2007
I haven't enjoyed a book this thoroughly in perhaps a decade. Everything you should have learned in computer school, but somehow missed. I've used at least a dozen techniques from this short masterwork (largely culled from HAKMEM -- devotees of that long-gone-but-not-forgotten first and greatest 'zine know this speaks to quality) in the year since I eagerly tore through my pre-ordered edition with almost sexual pleasure. Reading it is like a stroll down memory lane, except the road's been blasted broad and deep and out to the horizon.

Rediscover what it is to hack with delight. Hack in ecstasy; hack with joy; hack on!
154 reviews2 followers
February 7, 2019
This is more of a recipe books of techniques, things that many forget as we don't use it anymore. It is interesting, very deep. Not exactly practical among my circle.

I think I can scare some junior dev by showing off this book
4 reviews
February 15, 2024
If there's a book with a proper title, it's this one. Hacker's Delight is a book made for nerds, by a nerd.

As time goes by, knowledge is consolidated into snippets of great importance, delegating some of the grunt work and backbone tricks and tips to a second plane. This means that the newer generations don't get a lot of exposure to what makes some of the systems we're using tick. This book will show you what it was like to be a programmer eons ago (in a computer science scoped calendar) and there's a chance you will gain a whole new level of respect by our ancestry, where they weren't given everything in a silver plate and their code didn't just work everywhere, disregarding performance, the architecture, and so on...

I loved it, and I still check it out every once in a while when I need to find how to do certain operations faster, you know, those that we take for granted :)
204 reviews10 followers
May 6, 2024
This book in its own is a little gem, for most of the chapters it situates itself as a mixture of Knuths TAOCP, discrete mathematics and computer architecture. But I found it quite difficult and didn't really enjoy wrestling through it. I did appreciate the appendix with the visualization of common functions.
Profile Image for Blaze-Pascal.
294 reviews2 followers
Read
August 2, 2020
Sounds like a lot of people think this a clever book. Perhaps too clever for me... I will play around with programming in C for a bit and come back to this again and make a more learned position, but at this point I am completely unqualified to rate this book.
9 reviews2 followers
June 5, 2017
This book is good fun if you're into low level programming. It's full of nice bit-twiddling and clear explanations of elementary concepts like hamming codes,
Profile Image for Rebekah Mercer.
24 reviews5 followers
May 26, 2019
This book is a good read, but it is better suited to have on hand as a reference book than to read as a novel :)
3 reviews
May 19, 2024
Spying looks so easy now with your smart terminologies you really deserve your name!!! (geniusspyhack at gmail com)
Profile Image for Sergey Machulskis.
75 reviews6 followers
March 14, 2020
This is a collection of silly exercises like "implement this arithmetic operator using only division and negation".

In general hacks are nice. Fast inverse square root comes to mind as an example. But this book is too low-level for it.

I really wish I would never need a hack from this book.
Profile Image for Gregory Blake.
36 reviews4 followers
June 24, 2016
Hacker's Delight promises to tell the secrets of computer arithmetic, and it very much does that. From the basics of bitwise operations to Single-Error Correcting codes, this book contains an impressive repertoire of tricks for low-level software work.

If you're frustrated by branch mispredictions ruining your algorithm's performance, this book might have the branchless algorithm you're looking for.

The Integer Division chapters felt bloated and jammed with proofs, and the section on unusual bases for number systems was pretty much lifted straight from Donald E. Knuth's Art of Computer Programming, but Warren's friendly, conversational style made even these a pleasure. The first several chapters were quite enjoyable, and I particularly enjoyed the sections on the Sheep and Goats operation, Multiplication by Constants, Cyclic Redundancy Checks, Error Correcting Codes, and the Hilbert Curve.

The explanation of IEEE-754 floating points is the best I've gotten from any book, and Appendix C: A Gallery of Graphs of Discrete Functions should not be missed. Definitely a five-star read, but wear your math-hat -- Warren assumes you've already got one to wear.
Profile Image for Bishu.
7 reviews
April 15, 2014
Great stuff. Yes, I have read HAKMEM (or most of it) and yes bithacks was the the website that actually made me think about buying this book. I wont go as far as saying this book sucks or anything. I think its one of those classics if u are new to CS and havnt had a chance to mess with bits as much. Anyway, it was good, I like it fine!
Profile Image for Duncan.
47 reviews
Currently reading
December 18, 2010
lots of programming tricks, not sure if it's useful. But it's good to at least know about it. That said, knowing is requires significant effort.
32 reviews
Want to read
March 17, 2013
comprehensive algorithms wide for a hiker
Profile Image for Kevin Watkins.
9 reviews1 follower
April 17, 2013
A good book, excellent for basic bitshifting tricks. Don't try and read it cover to cover during your commute to work though, it is hard going at times...
9 reviews
March 9, 2016
Why anyone would want to write code like this is beyond me, unless of course you are trying to win the annual obfuscated C contest then it's probably a godsend.
Profile Image for Guillermo Quezada.
2 reviews3 followers
Read
November 21, 2018
If you're into programming this book is great. There are many algorithms in the book, some of them might just stay as theoretical and amazing hack tools, applicable in very specific situations. For the most part, I enjoyed learning new ways of processing data with complex constrains.
Displaying 1 - 24 of 24 reviews

Can't find what you're looking for?

Get help and learn more about the design.