The Dao - Intro
Lesson1: The hacker spirit is; in oneness. "You" don't exist, therefore "your" skills are not "yours".
They're gifts offered throught the many iterative and parallel incarnations of the spirit.
Lesson2: The hacker spirit knows no gender. Spirit knows no form and spirit knows no sides. It is the balance source of balance.
Lesson3: The hacker spirit imbudes all and is omnipotent.
Lesson4: The hacker spirit knows not bugs. If bugs, the flesh is week. One must meditate on the Dao.
Lesson5: The hacker spirit wastes not bits, nor cycles.
The hacker spirit of the programmer who wrote that Quake RSQRT poetry (people wrote theses about the magic constant) is still unidentified (even the known masters - Carmack, Abrash, Mathisen, Romero - wo made the code public remain ignorant of its origins).
Only an egoless master of the Dao could disolve their ego to let the infinite intelligence immaculately reflect through the work and live on forever in the memories of those who recognize an enlightened being's work.
That tweet is typical "girl code glitter" and the spirit behind it is no hacker spirit. It is full of disappointing pride and shows no class.
Reinventing the max(a, b) is no big deal. A little analysis:
if (a < b) return b;
else if (a > b && b < a)
return a;
Most non initiates care less about compilation. Code isn't written for people, it is written for a compiler which in turn produces machine code.
Compilers have a spark of hacker spirit doing magic on behalf of the non initiate's ignorance - dead code elimination, loop unrolling, cache blocking, expression simplification, branch prediction, ...
When a non initiate is initiated into what's behind the veil, the newl initiate is humbled by the Grace of the spirit.
The condition of the else statement above will obviously be reduced by the compiler to if (a > b) rather than if (a > b && b < a), the condition being always satisfied on both sides. The only acceptable implementation of such operation is the following.
#define max(a, b) ((a) > (b)) ? (a) : (b) //A bit of Lispiness for the preproc.
This typeless macro can span any type for which the operator > is valid and will be handled by the preprocessor which will cause an "inlining" of the expression over a function call. Of course, the compiler will optimize the expression according to your desires (-O1, -O2, -O3, ...). An optimized integer implementation could also be expressed as follows,using a XOR and a compare:
static inline int max(int x, int y) { return x ^ ((x ^ y) & -(x < y)); } //
or as follows, using subtractions and a shift:
static inline int max(int x, int y) { return x - ((x - y) & ((x - y) >> (sizeof(int) * 8 - 1))); }
Funny comment, first comment, hilarious: https://github.com/yaspr/bitwise/blob/master/bitwise_util.c
Flip it! (0 ~ 1)