Comment by alexashka
6 years ago
Why do we need ABI stability for these features?
Libraries can evolve just fine by providing backward compatible changes as far as I can tell?
6 years ago
Why do we need ABI stability for these features?
Libraries can evolve just fine by providing backward compatible changes as far as I can tell?
Yes that's right: ABI stability is all about nailing down which changes are "backwards compatible."
In C++, you might wish to add a field to a struct, or add a new virtual method, or change the inheritance hierarchy, or the type of a parameter, etc. But such changes are not ABI compatible and will break every app until they are recompiled. The C++ ABI compat story is very strict.
Modern ObjC has a more generous policy, leveraging its dynamic nature. For example you can add fields or methods to classes, without recompiling dependencies. But you pay an optimization penalty, since the apps have to defer offset calculation until runtime.
Swift attempts to have its cake and eat it too. Swift enables you to be explicit about which types might change in the future, and which types are "frozen" and can be aggressively optimized. Furthermore you can explicitly draw the ABI boundaries are: THESE parts are always compiled together and so intra-references may be aggressively optimized, but THOSE parts may need to evolve separately so enforce an ABI there.
> But you pay an optimization penalty, since the apps have to defer offset calculation until runtime.
isn’t that penalty only one time, when the first message is sent? after that it seems pretty dang fast [1]
[1] https://mikeash.com/pyblog/friday-qa-2012-11-16-lets-build-o...
Library can't provide backwards compatibility or even any compatibility if newer version of compiler decides to change the layout for a structure or an enum thus breaking ABI for everything including parts of library that didn't change.