Remix.run Logo
▲ hehbot 2 hours ago

Anyone who's saying "Dynamic linking sucks and is not required" is my friend without question

▲paaloeye 44 minutes ago | parent | next [-]

What's exactly wrong with dynamic linking?

▲vinyl7 41 minutes ago | parent [-]

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.

▲paaloeye 19 minutes ago | parent [-]

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.

▲publlus_enigma an hour ago | parent | prev | next [-]

One of the biggest missteps in software development, to be sure.

▲JoshTriplett 18 minutes ago | parent [-]

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.

▲ozgrakkurt an hour ago | parent | prev | next [-]

Even the concept of linking only exists because of history at this point right?

▲sznio an hour ago | parent | next [-]

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.

▲kevin_thibedeau an hour ago | parent | next [-]

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.

▲mjr00 43 minutes ago | parent | next [-]

The good news is we're trending back toward $1000/MB RAM. Maybe it's time for a dynamic linking comeback!

▲fooqux 42 minutes ago | parent | prev [-]

> Important when RAM was over $1000/MB.

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

▲uecker an hour ago | parent | prev | next [-]

It is an important feature to roll out security updates.

▲pjmlp an hour ago | parent | prev [-]

And plugins, although one might argue multiple processes with OS IPC is more secure and stable, given the hardware resources.

▲RetroTechie 44 minutes ago | parent | prev | next [-]

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.

▲jayd16 31 minutes ago | parent [-]

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...

▲ an hour ago | parent | prev [-]
[deleted]
▲rfgplk 34 minutes ago | parent | prev [-]

[dead]