Re:Why is processing a sorted array faster than an unsorted ...
by cdavid on Wednesday October 10, 2012 @03:45PM
(#4637833)
This is not correct: there are things that can be faster than C because of the compilation aspect (the compiler can only optimize with the information it has, some of them can only be known at runtime).
A good example is iteration over non trivial, multi-dimensional structures: if you iterate over a single dimension, then some variables become actual constant, but this can only be known once you know the iterator parameters (i.e. even profile-guided optimization would not work).
You could obviously implement a runtime-based optimizer in C, but then the assertion that you can never beat C is a tautology.
A good example is iteration over non trivial, multi-dimensional structures: if you iterate over a single dimension, then some variables become actual constant, but this can only be known once you know the iterator parameters (i.e. even profile-guided optimization would not work).
You could obviously implement a runtime-based optimizer in C, but then the assertion that you can never beat C is a tautology.