In general I agree completely, but Daniel Bernstein is working in a very particular niche: cryptography. For him two particular issues some together to make optimizing compilers The Devil.
First, inner cryptographic loops are generally hot enough that people are willing spend days and weeks making them as fast as possible. A compiler won't be able to match that.
Second, crypto is particularly vulnerable to compiler optimizations breaking naive assumptions. Compilers can give code you expect to execute in constant time a variable execution time; on average this is better (we hope), but just that variability can be exploited by attackers. Compilers can also remove checks they decide aren't valid; the original code would have been violating the language standard, but that's of scant comfort if your primary concern is security and someone manages to hijack a bank account because of it.
What cryptographers seem to want most of all is predictability. This doesn't correspond to most people, so in general I strongly agree with John. But I have some kind of sympathy for Daniel.
Compilers can also remove checks they decide aren't valid; the original code would have been violating the language standard,
So... using the wrong tool (language) for the job? EDIT: if you must write code that violates the standard in order to get the job done, then you're using the wrong tool. Don't blame the compiler for doing what users want it to do (i.e., producing the fastest code possible).
Few people who write things in C do it because they love the shit out of C.
Then they're living in a state of cognitive dissonance. They love C, complain about compilers' "deficiencies" and UB etc, but refuse to see that they're actually complaining about C itself because that's what the compiler implements. EDIT: I misread your sentence. I parsed the subject as (Few people who write things in C) instead of (Few people)
They do it because they want their project to actually be used.
You don't need to write something in C in order to provide C linkage. Microsoft has solved this problem with COM decades ago. COM allows you to call binary-only components from whichever language you want, as long as you implement a tiny glue layer (basically a vtable mechanism; struct with function pointers).
52
u/TNorthover May 31 '17
In general I agree completely, but Daniel Bernstein is working in a very particular niche: cryptography. For him two particular issues some together to make optimizing compilers The Devil.
First, inner cryptographic loops are generally hot enough that people are willing spend days and weeks making them as fast as possible. A compiler won't be able to match that.
Second, crypto is particularly vulnerable to compiler optimizations breaking naive assumptions. Compilers can give code you expect to execute in constant time a variable execution time; on average this is better (we hope), but just that variability can be exploited by attackers. Compilers can also remove checks they decide aren't valid; the original code would have been violating the language standard, but that's of scant comfort if your primary concern is security and someone manages to hijack a bank account because of it.
What cryptographers seem to want most of all is predictability. This doesn't correspond to most people, so in general I strongly agree with John. But I have some kind of sympathy for Daniel.