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 (26)

  1. Anyone who's saying "Dynamic linking sucks and is not required" is my friend without question
    Replies (3)
    1. One of the biggest missteps in software development, to be sure.
      Replies (1)
      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).

    2. Even the concept of linking only exists because of history at this point right?
      Replies (2)
      1. No matter history it seems pretty useful to build a library just once and then use the built artifact multiple times, rather than compiling it over and over from scratch.

        I do definitely agree for dynamic linking though. It was mostly a disk space saving measure. If one insists it could be a compatibility feature too.

        Replies (3)
        1. It is an important feature to roll out security updates.
          Replies (1)
          1. The future of computing is offline (or local trusted intranets)
        2. And plugins, although one might argue multiple processes with OS IPC is more secure and stable, given the hardware resources.
          Replies (1)
          1. RPC protocols just seem really inefficient. An in-process plugin architecture can share data synchronously in a few CPU instructions instead of asynchronously in tens of thousands. RPC architectures require both sides to duplicate state from the other side so they can query it efficiently while in-process architectures allow you to just call a get function.
            Replies (1)
            1. There are other ways to do OS IPC besides RPC, like memory segments.

              But yeah it comes with a cost versus plain dynamic linking.

        3. It was a RAM saving measure since everyone on multiuser unix systems could share text and rodata segments. Important when RAM was over $1000/MB.
          Replies (2)
          1. The good news is we're trending back toward $1000/MB RAM. Maybe it's time for a dynamic linking comeback!
          2. > Important when RAM was over $1000/MB.

            So just like today then? (Tongue only partially in cheek.)

      2. Isn't the point of dynamic linking to have each piece of functionality in 1 place? Broken -> fix library -> fixes issue for all apps using that library.

        Sounds like a good idea in general. Memory savings are a welcome side-effect.

        Static linking is simpler but does away with those advantages.

        I suppose much hatred against DL isn't the concept itself, but specific implementations. Like, any which do the versioning / dependency management badly.

        Replies (1)
        1. But in practice you end up with users using untested configurations of software, subtle, minor-version DLL changes end up causing issues.

          You can't just strip and inline the parts of the lib you need. You still probably need to pack in the DLLs you want in case the end users might not have a way to easily procure them elsewhere. Its a big ol' mess...

    3. What's exactly wrong with dynamic linking?
      Replies (1)
      1. Software A depends on version 1.34.5678 but my software requires version 1.35.678 and unfortunately 1.35.678 breaks Software A that needs 1.34.5678 and so now I need two DLLs on my machine anyway so all the complexity was for nothing. Now all software just bundles their own copy of the DLL.

        Then I want to use Library Z but it requires version 1.45 of the DLL and I need to use 1.47 for a new feature but it is incompatible with Library Z and so now there is a conflict that can't be resolved.

        Software T requires version 2.3 but my Linux distribution only ships version 1.8 and so I can't use that software until the distro updates at some indeterminate time in the future.

        Software G requires version 2.3 but Ubuntu ships version 1.7 and Gentoo ships 1.97 and Debian only has 1.6 installed so the number of linux distros that can run the software is limited.

        Replies (3)
        1. This is DLL hell, well-known problem. Replace DLL with Python, NPM, Java and you have exactly the same problem.

          If dynamic linking is used right, it has a lot of advantages. libSystem/dyld_shared_cache in darwin/XNU is a good example how to do it right.

          Replies (1)
          1. I think the problem is that the problem gets trivialized when in reality, it's more difficult than we realize.

            I want to use LibraryA in ProgramA and in ProgramB. It would be nice if they could both use the same binary, that way I can save some storage. Also, if I notice a problem in LibraryA, I could fix that and just replace that.

            But inevitably, you get to a position where you need to make a change to LibraryA that would make it incompatible with previous versions. There's no nice, clean way to have both all producers and all consumers be both backwards and forwards compatible. Or, at the very least, you have to be aware that's what dynamic linking is asking of your software, that it be both backwards and forwards compatible.

            Replies (1)
            1. Reality: you save up all your breaking changes and call it libmylibrary2 when you make them
        2. Nix has basically solved this for many years. You can have multiple versions of a dll if someone's a special snowflake, and get sharing if they're not. Without needing to specifically put your shared libraries in a good base layer like Docker. I've been using NixOS for 9-10 years now on all of my computers and it's been pretty much completely hassle free. LLMs can now also manage your config for you so you don't even need to learn it.

          The biggest problem is that much like Haskell or Scala, using it causes you to realize that you hate working with anything else, likely making your job satisfaction decrease because you're never going to move your org off Ansible or whatever.

        3. That is very much a developer problem. The version conflicts always have carelessness at its root. You should be able to update the system to version 1.97 and have everyone that relies on 1.x to be happy. The add a package lib2 for the ones that wants 2.x.

          Libraries developers breaking API contracts and developers hard requiring only the latest version is what is making a mess.

          If there is one thing I like about the BSDs and distros like alpine and arch is how easy it is to create a new package spec. Also easy to setup a repo.