4 ms·
Abstraction allows us to substitute one thing for another without breaking compatibility. This is at the heart of both API-level compatibility and also most opt
by skybrian 8y ago
Abstraction allows us to substitute one thing for another without breaking compatibility. This is at the heart of both API-level compatibility and also most optimizations. If two implementations weren't considered equivalent, we wouldn't be able to do the substitution without breaking things. On the other hand, if the change didn't have some important, user-visible difference (such as performance), there would be no point in doing the substitution.
Now consider that most optimizations are enabled by inlining, which means that changing the internal details of a function could break optimizations in calling code and this could cause performance regression.
A stricter API could prevent regressions (some bad changes are disallowed) but it also prevents good changes (they break compatibility or are disallowed optimizations).
Language designers get to decide what "equivalent code" means using various forms of abstraction, but there is not going to be a perfect answer.