Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The technicalities behind Swift's work on ABI stability are very interesting but I remain unconvinced developers care about ABI stability nowadays; outside security updates and the very basic layers (syscalls, WinAPI...).

In the past, ABI stability was way more important for many companies because there were many more closed source dependencies, way less access to online updates, way less emphasis on CI/CD, etc.

The argument for size by avoiding several std runtimes is strange in 2019, specially considering Apple's policy of deprecating things and forcing devs to update apps constantly.



ABI stability is not about size! It's about enabling the libraries to evolve simultaneously with the app.

For example, in the next version of the OS, all table views get type select. Combo boxes work better with screen readers. Menus get dark mode. etc.

An OS can provide much more than libc or Win32 "basic layers". It can provide a whole UI vocabulary, and apps which use its frameworks enjoy new features as the OS improves. That's the hope at least.


ABI stability is absolutely (also) about size though, one of the big issues iOS developers have/had with Swift is/was that it would make the size of the bundle explode (compared to an equivalent objective-c application) as the application would need to bring along much of the standard library.

Until there starts being core swift-only APIs, your point is already solved because regardless of the Swift library the underlying functionality and OS interaction is mediated through a C library which is dynamically linked.


In the linked blog post they mention size explicitly:

> ABI stability for Apple OSes means that apps deploying to upcoming releases of those OSes will no longer need to embed the Swift standard library and “overlay” libraries within the app bundle, shrinking their download size; the Swift runtime and standard library will be shipped with the OS, like the Objective-C runtime.

For new UI backends you don't need a different interface, you provide the new UI under the old interface. If your new elements have new behavior you will need to update your app anyway.


Sorry, you are correct, I was imprecise.

"ABI stability" is about defining an ABI. "ABI resilience" is defining how libraries can evolve in a binary compatible way. Stability is a precursor to resilience.

Apple would like to write libraries in Swift, but those libs have to participate in an ABI that is stable (so apps can use them) and resilient (so Apple can evolve them without breakage).

> For new UI backends you don't need a different interface, you provide the new UI under the old interface

The challenge is how to provide new UI features without breaking existing apps. For many UI frameworks (the web in particular) the compiler/runtime has a global view and can sort it out. But if both the app and library are separately compiled, the problem becomes trickier.


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.


ABI (and module) stability is a big thing for people shipping iOS frameworks.


Yes, but the guarantees Swift provides are not a requirement for that.


They are somewhat important if you cannot recompile the framework to match the version of Swift your app is using.


ABI stability benefits users too. It reduces payload sizes because runtime can reside in the OS as a shared library.


I answered to that in the last paragraph. I don't see the appeal in 2019, in particular in the Apple ecosystem where backwards compatibility is not respected that much.


How is that irrelevant? If the app you install is 20MB smaller it is still 20MB not taken from your data cap and it is still less data to transfer, thus faster. Before ABI stability every iOS app had to come with bundled Swift runtime/libs. Event if two apps used exactly the same version, you'd still get two copies. With ABI stability apps can use what iOS provides and no longer need own copies.


20 MB is a ridiculous amount compared to anything else going on in your phone, including sending a few high res shots. Many apps and iOS updates are an order of magnitude bigger, and they are not even games.

If size was such a huge concern, Apple would have provided it a long time ago in Swift.


Size is a huge concern. The article is exactly about why it wasn't done a long time ago, because it is a very hard problem.


In this a real world advantage? Are iOS and OSX binaries significantly smaller than Android, Windows, and Linux binaries? Not noticeably in my experience but I could be wrong.


> significantly smaller than Android, Windows, and Linux binaries

Linux distributions do use dynamic linking (.so files are dynamic library) like OSX does (but with .dylib).

Windows also has dynamic linking (.dll), but they are less frequently used because the lack of a package manager with dependency management requires application vendors to distributes non-system libraries with their application anyway.


Hmm, then why is the article written like Swift has any significant advantage?


You could instead interpret it as C++ and Rust (minus the C like parts) have disadvantages. Swift performed some compiler heroics to keep the advantages while still having similar features to them.


Constantly? The Mac 32-bit x86 ABI was supported for 14 years. 32-bit iOS lasted 9 years. Those are the only two ABI switches this decade. And how does "forced" updates negate the size-of-code on disk/memory issue?


We are not just talking about arch/system ABIs but language/library ABIs.

In any case, 14 years is definitely a very short time for arch/system ABI support, specially compared to Linux or Windows which will basically never kill x86 ABI support.

Apple has just killed thousands of apps and games that people are using.


> which will basically never kill x86 ABI support

Ubuntu decided to drop i386 support since 19.10, for one. Though, x86_64 kernel still supports running 32-bit software and multilib support is there. The kernel is unlikely to drop support for the architecture, but if the distributions stop including it it will die off at some point.


In principle yeah Win32 ABI is still supported. In practice that has become untenable, so for old enough software they just run it in a Windows XP virtual machine instead.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: