Found in 15 comments on Hacker News
news_to_me · 2022-12-19 · Original thread
I just got a copy of Hacker's Delight, which seems to show the same sorts of tricks. I haven't read very much of it yet, but I wonder how many of these came from that book or a common source. It would be fun to read more about the history of these tricks.

https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...

mindcrime · 2022-08-17 · Original thread
What is the proper way to achieve that kind of skill?

I don't know that there's any one specific "proper" way, and as the old saying goes "many roads lead to Rome." But I do think the spirit of this old saw applies:

A fellow goes to New York to attend a concert, but gets lost. He spots another fellow who’s carrying a violin case. “Sir, can you tell me how to get to Carnegie Hall?” The musician smiles and says, “Practice, practice, practice.”

Are there any must read topics/subjects?

I think many people approach this from different directions, but you can pretty much always figure that it helps to get "close to the hardware" and understand things from first principles as much as possible, and then build your knowledge up from that base. So if you start from literally understanding how you make a logic gate from a transistor, and then up to how AND,OR,NAND,NOR,NOT etc. gates are used to implement digital logic, and up through some basics of how a CPU executes code, yadda yadda, you're probably on a good path. Then from the code level, understanding assembly language for at least one architecture and having at least some notion of how the assembly mnemonics map to the CPU ISA and what's going on at the hardware level. What are registers and how are they used, how is data shuffled around between different parts of memory, etc. From there you can build up to understanding different parts of the computing "stack" - the operating system kernel, standard library, memory models, etc.

All of that said, I don't claim that the above is the way, just a way. I'm sure there are people who use the title "hacker" who didn't do any of that. All "many roads".

The other thing I'll throw out there is that math comes into play at some levels depending on exactly where your interests take you. It can't hurt to pick up some basic number theory, boolean algebra, computability theory, etc. Some of the kinds of things that come up in the book Hackers Delight[1] could be of interest.

Another thought - if you haven't read Steven Levy's book Hackers: Heroes of the Computer Revolution[2] give that a read. It's not a super technical book, being more about the "spirit" or essence of what "hacking" and "hackerdom" are. But I would say that might be as valuable as the technical stuff in many ways.

Also, reading the various pg essays[3] and/or Paul's book Hackers and Painters[4] probably can't hurt either.

Beyond that, there's a whole laundry list of books and resources one might mention as seminal or defining works of "hackerdom". Things like the TCP/IP Illustrated books by Stephens, The C Programming Language by Kernighan and Ritchie, The Cathedral and the Bazaar by esr, the Internetworking with TCP/IP books by Comer, Advanced Programming in the UNIX Environment by Stephens, a lot of early LISP material by McCarthy and others, a lot of the "AI Series" papers from MIT's CSAIL lab, etc., etc. And that's not close to a comprehensive list, if such a thing could be said to exist. Just some examples of the kinds of things people who associate with hackerdom tend to get into.

Last thought - I would cite "curiosity" as the most important defining trait for becoming a "hacker". If you're never satisfied with your current level of knowledge, always want to probe and dig deeper, and understand more and more and more and more of how things work and why things are the way they are, then in my book you're pretty much a hacker. I'd say try to cultivate that insatiable desire to learn and just dive in and don't worry too much about the "proper" road.

[1]: https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...

[2]: https://www.amazon.com/Hackers-Computer-Revolution-Steven-Le...

[3]: http://www.paulgraham.com/articles.html

[4]: https://www.amazon.com/Hackers-Painters-Big-Ideas-Computer/d...

valbaca · 2022-07-12 · Original thread
The book linked at the bottom is a treasure trove of bitwise fun:

"Hackers Delight" https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...

drallison · 2021-12-31 · Original thread
Understanding Software Dynamics (Addison-Wesley Professional Computing Series) 1st Edition by Richard L. Sites (https://www.amazon.com/Understanding-Software-Addison-Wesley...)

This is a recent book and I have not completed reading it but I know already is it destined to become a classic. 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 Programming Pearls books. C is a great (and permissive) programming language. Jon shows how the language can be exploited for gain performance. Evil but effective.

Hacker's Delight 2nd Edition by Henry Warren (https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...)

The Hacker's Delight is exactly what Hank Warren intended--a collection of tricks and facts that programs can exploit. It's informative on many levels. It uses deep knowledge of how numbers (and other mathematical objects) work to compute useful information. And it shows how seemingly arcane information can be useful. For a programmer excited by the fabric of programs, it is a continual delight.

The first edition has a clarity and compactness that I find appealing. The second edition has additional material. When you get through all of the Delights you can read Knuth Volume 4 which embeds more arcane and useful knowledge.

jhallenworld · 2020-08-24 · Original thread
Well I have an important resource for this, the book "Hacker's Delight":

https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...

This book will tell you how to efficiently generate condition flag values such as carry and overflow. It's easy when when you have extra bits available (such as emulating an 8 or 16 bit processor on a 32-bit processor), but less obvious when you are emulating a 32-bit processor on a 32-bit processor from a high level language.

jmalicki · 2020-07-23 · Original thread
For some of the "clever tricks" at higher levels, Hacker's Delight is a great treasure trove - it's not x86-64 specific, as a lot of the tricks are applicable to many CPUs, but it helps understand some of the seemingly bizarre tricks.

https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...

Erwin · 2019-10-28 · Original thread
If you enjoy this sort of thing, this book is full of bit twiddling algorithms you never thought possible: https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...
filereaper · 2018-05-11 · Original thread
I'd recommend anyone who's into bit-level hacking to have a copy of Henry Warren's Hackers Delight [1]

Many of those nifty tricks are found in production systems today.

[1] https://www.amazon.ca/Hackers-Delight-2nd-Henry-Warren/dp/03...

jdblair · 2017-11-19 · Original thread
If you enjoy these bit twiddling hacks, I recommend "Hacker's Delight," by Henry Warren.

Author's website: http://www.hackersdelight.org

2nd edition on Amazon: https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...

microtherion · 2017-06-19 · Original thread
This seems to have some overlap with Henry Warren's Hacker's Delight: https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...
todd8 · 2016-10-09 · Original thread
Depending on your level of programming ability, one algorithm a day, IMHO, is completely doable. A number of comments and suggestions say that one per day is an unrealistic goal (yes, maybe it is) but the idea of setting a goal and working through a list of algorithms is very reasonable.

If you are just learning programming, plan on taking your time with the algorithms but practice coding every day. Find a fun project to attempt that is within your level of skill.

If you are a strong programmer in one language, find a book of algorithms using that language (some of the suggestions here in these comments are excellent). I list some of the books I like at the end of this comment.

If you are an experienced programmer, one algorithm per day is roughly doable. Especially so, because you are trying to learn one algorithm per day, not produce working, production level code for each algorithm each day.

Some algorithms are really families of algorithms and can take more than a day of study, hash based look up tables come to mind. First there are the hash functions themselves. That would be day one. Next there are several alternatives for storing entries in the hash table, e.g. open addressing vs chaining, days two and three. Then there are methods for handling collisions, linear probing, secondary hashing, etc.; that's day four. Finally there are important variations, perfect hashing, cuckoo hashing, robin hood hashing, and so forth; maybe another 5 days. Some languages are less appropriate for playing around and can make working with algorithms more difficult, instead of a couple of weeks this could easily take twice as long. After learning other methods of implementing fast lookups, its time to come back to hashing and understand when its appropriate and when alternatives are better and to understand how to combine methods for more sophisticated lookup methods.

I think you will be best served by modifying your goal a bit and saying that you will work on learning about algorithms every day and cover all of the material in a typical undergraduate course on the subject. It really is a fun branch of Computer Science.

A great starting point is Sedgewick's book/course, Algorithms [1]. For more depth and theory try [2], Cormen and Leiserson's excellent Introduction to Algorithms. Alternatively the theory is also covered by another book by Sedgewick, An Introduction to the Analysis of Algorithms [3]. A classic reference that goes far beyond these other books is of course Knuth [4], suitable for serious students of Computer Science less so as a book of recipes.

After these basics, there are books useful for special circumstances. If your goal is to be broadly and deeply familiar with Algorithms you will need to cover quite a bit of additional material.

Numerical methods -- Numerical Recipes 3rd Edition: The Art of Scientific Computing by Tuekolsky and Vetterling. I love this book. [5]

Randomized algorithms -- Randomized Algorithms by Motwani and Raghavan. [6], Probability and Computing: Randomized Algorithms and Probabilistic Analysis by Michael Mitzenmacher, [7]

Hard problems (like NP) -- Approximation Algorithms by Vazirani [8]. How to Solve It: Modern Heuristics by Michalewicz and Fogel. [9]

Data structures -- Advanced Data Structures by Brass. [10]

Functional programming -- Pearls of Functional Algorithm Design by Bird [11] and Purely Functional Data Structures by Okasaki [12].

Bit twiddling -- Hacker's Delight by Warren [13].

Distributed and parallel programming -- this material gets very hard so perhaps Distributed Algorithms by Lynch [14].

Machine learning and AI related algorithms -- Bishop's Pattern Recognition and Machine Learning [15] and Norvig's Artificial Intelligence: A Modern Approach [16]

These books will cover most of what a Ph.D. in CS might be expected to understand about algorithms. It will take years of study to work though all of them. After that, you will be reading about algorithms in journal publications (ACM and IEEE memberships are useful). For example, a recent, practical, and important development in hashing methods is called cuckoo hashing, and I don't believe that it appears in any of the books I've listed.

[1] Sedgewick, Algorithms, 2015. https://www.amazon.com/Algorithms-Fourth-Deluxe-24-Part-Lect...

[2] Cormen, et al., Introduction to Algorithms, 2009. https://www.amazon.com/s/ref=nb_sb_ss_i_1_15?url=search-alia...

[3] Sedgewick, An Introduction to the Analysis of Algorithms, 2013. https://www.amazon.com/Introduction-Analysis-Algorithms-2nd/...

[4] Knuth, The Art of Computer Programming, 2011. https://www.amazon.com/Computer-Programming-Volumes-1-4A-Box...

[5] Tuekolsky and Vetterling, Numerical Recipes 3rd Edition: The Art of Scientific Computing, 2007. https://www.amazon.com/Numerical-Recipes-3rd-Scientific-Comp...

[6] https://www.amazon.com/Randomized-Algorithms-Rajeev-Motwani/...

[7]https://www.amazon.com/gp/product/0521835402/ref=pd_sim_14_2...

[8] Vazirani, https://www.amazon.com/Approximation-Algorithms-Vijay-V-Vazi...

[9] Michalewicz and Fogel, https://www.amazon.com/How-Solve-Heuristics-Zbigniew-Michale...

[10] Brass, https://www.amazon.com/Advanced-Data-Structures-Peter-Brass/...

[11] Bird, https://www.amazon.com/Pearls-Functional-Algorithm-Design-Ri...

[12] Okasaki, https://www.amazon.com/Purely-Functional-Structures-Chris-Ok...

[13] Warren, https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...

[14] Lynch, https://www.amazon.com/Distributed-Algorithms-Kaufmann-Manag...

[15] Bishop, https://www.amazon.com/Pattern-Recognition-Learning-Informat...

[16] Norvig, https://www.amazon.com/Artificial-Intelligence-Modern-Approa...

kyteland · 2015-05-25 · Original thread
There is, and I can't recommend it highly enough.

http://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/03...

Artemis2 · 2015-02-21 · Original thread
There are truly systems that are so elegant that they feel natural, just right. Functional programming patterns are one of these.

Additionally to the papers you mentioned, there is the paper Amazon published on Dynamo, which also spawned Cassandra and Riak, marvels of modern engineering. Here is a link: http://www.allthingsdistributed.com/files/amazon-dynamo-sosp...

I'd advise you to read Hacker's Delight (http://www.amazon.com/dp/0321842685). It's a tough read, but there's so much to learn in there!

Hacker's Delight [1][2] is an amazing book dedicated to discussing about all kinds of bit hacking, including fast integer square root, cube root calculation.

[1]: http://www.hackersdelight.org/

[2]: http://www.amazon.com/Hackers-Delight-Edition-Henry-Warren/d...

arh68 · 2013-12-08 · Original thread
Hacker's Delight - http://www.amazon.com/Hackers-Delight-Edition-Henry-Warren/d...

EDIT: .. and a good coffeemaker. :)

Fresh book recommendations delivered straight to your inbox every Thursday.