Unofficial Hacker News companion — get notified on comment replies, and more.

All software sucks (2007) (opens external site)

162 points by archargelod 8 hours ago harmful.cat-v.org 190 comments (opens Hacker News) Vote (opens Hacker News)

View full thread · View on Hacker News

Comment thread (5)

  1. It made sense for several tradeoffs present at that time.

    - Size: shared libraries save some disk space. But disks are absurdly large these days compared to executable code, and in practice, code is never the thing that's going to fill up your disk. Your disk is going to be full of data, not code. (Or whichever hybrid of "code" and "data" you want to call a set of neural network weights...)

    - Memory: shared libraries can theoretically have the same mapped code pages in memory across several processes. Marginally more interesting, but still not where most of your RAM is going today.

    - Upgrades, maintenance, and build time: the expectation that if there's a bug in the shared library, you can update the shared library, and not need to update all the software built atop it. The most interesting reason that's still remaining, but not enough to put up with the tradeoffs of dynamic linking. You'd still have to restart all the applications that have that shared library loaded, so you don't get any logistical isolation there (whereas you would with components communicating via some RPC protocol). You may well have to rebuild things anyway, if the bug is in anything that gets inlined into the application. You have versioning problems, and all the clever schemes like symbol versioning are used by vanishingly few libraries (mostly glibc). And ultimately, rebuilding software isn't nearly as expensive as it used to be, because we have a lot more computing power now.

    Dynamic linking seems like a tradeoff designed when the most interesting shared library on your system was libc. It imposes logistical and efficiency costs on everything. And it doesn't buy enough to be worth it.

    If you want to have shared components that can be upgraded independently, have services communicating via RPC.

    Replies (2)
    1. Dynamic linking has another tradeoff: an easy ad-hoc ABI layer. A compiler cannot static link to glibc, OpenGL, Vulkan, or X11 to make a portable video game or graphical application. Saving the effort of designing an RPC protocol has pushed incidental complexity to other places. Other programming languages must include C compatibility and SysV ABI compatibility. Other programming languages must interface with a standard ELF linker to pull C symbols. Other program loaders must include glibc compatibility (gcompat for musl-libc).

      As you said, logistical and efficiency costs.

      Replies (1)
      1. It's all about where you draw the layer boundaries, isn't it? On Windows you don't even get to customise the program loader, because why would you need to. If you use an alternative libc (which is normal on Windows - there is no single unified libc - not even the one called UCRT) you still have the same dynamic loading interface and can load modules compiled with different libcs or no libc.

        The most annoying tradeoff with that is you can't pass libc pointers across DLL boundaries. You can't malloc something in one DLL and free it in another. You either use an allocator from a known DLL (like LocalAlloc/LocalFree) or you give your DLL a wrapper call to free so you can free the things it returns.

        Replies (1)
        1. Yes, all about how the shape of a layer boundary affects other social and technical areas. A shared library takes the shape of a C language implementation, while an RPC protocol over sockets takes the shape of the kernel interface. Because important system components change between systems, and those components only provide a C interface (instead of a language-neutral interface), the necessity of dynamic linking forces the supremacy of a particular C implementation (glibc ld.so). Other C implementations and other programming languages must accommodate, or else suffer incompatibility.

          You shared a great example. A unified program loader allows multiple libc implementations. However, no single unified libc means no passing libc pointers across DLLs.

    2. How do you build a graphics driver that can run on a variety of hardware with a shared interface without dynamic linking? It must be in-process and userspace; RPC is not tenable for performance. And you need to be able to update it independently so that you can still run Batman: Arkham Asylum in 2026 on hardware that didn't exist in 2010.

      Everyone hates dynamic linking, but it's necessary. Modern versions like Apple's dyld shared cache avoid a lot of the problems (at the cost of centralization).