The article is fun to read, but I’m not convinced C’s lack of generics prevents it from supporting fast generic sort. Imagine qsort() being a header library, and a compiler that can inline heavily. What would prevent C from inclining the compare() function, recover the element types and produce specialized sorts?

The compare function is passed by value (like all things in C) and the preprocessor is not smart enough to find the code.

There was a C library - posted here but I cannot remember the name - which used the preprocessor to avoid invoking a function call per comparison. You'd use it something like this:

#define SORT_ELEMENT_TYPE int

#define SORT_COMPARE(a, b) sign(a - b)

#include "specialized_sort.h"

And the header would define a function with the following signature:

int sort_int(int[] a, size_t n);

Maybe not it, but STC (https://github.com/tylov/STC) and CTL (https://github.com/glouw/ctl) both use this define method for creating data structures and linking up compare functions for them.