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

  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.