20 years ago, there was (almost) no any compilers optimizations. So, we started to use some hacks, such as:
- Use pointers, not array indexes.
- Don’t use small functions (such as
swap()), use macros or write the code directly.
Today, we have complex compiler optimization. Array indexes and pointer are same. If we use -O3 (I know, it’s dangerous), compiler will remove all functions except main().
So, the small hacks in the old books (Programming Pearls, The C Programming Language) are useless today? They are just make the code more unreadable?
Programming Pearls is about optimisation at the algorithm level, not at the code level, so it’s still highly relevant today.
Code micro-optimisations are another story though, and many of the old tricks are now either redundant or even harmful. There are still important techniques that can be applied to performance-critical code today, but these also may become redundant/harmful at some point in the future. You need to keep up-to-date with advances in CPU micro-architecture and compiler technology and use only what’s appropriate (and only when absolutely needed of course – premature optimisation being the root of all evil.)