News for hackers. Stuff that matters.
Re:“Shared libraries are not a good thing in general” by OnlyOneCannolo on Saturday May 01, 2021 @08:22PM (#27011209)
Not defending it for general use, but dynamic linking can be very useful for test and instrumentation. Also sometimes for solvers and simulators, but that's even more niche.
Re:“Shared libraries are not a good thing in general” by Banana699 on Saturday May 01, 2021 @09:15PM (#27011496)
Can you please elaborate? Why would the ability to change the library version at runtime be useful for testing? and what aspect of this is useful for simulators and solvers?
Re:“Shared libraries are not a good thing in general” by dathinab on Saturday May 01, 2021 @09:43PM (#27011660)
You compile a version of the dependency which intentionally behaves different (e.g. introduces random network errors, random file parsing errors, etc.) and "inject" it into a otherwise functional setup to check if all other parts including error reporting and similar work.

There are always other ways to archive this but using (abusing?) the dynamic linking is often the simpler way to set it up.

> and what aspect of this is useful for simulators and solvers?

Duno, but some programs allow plugin in different implementations of the same performance critical functionality so that you can distribute a binary version and then only re-compile that part with platform specific optimizations. If that is what the author is referring to I would argue today there are better ways to do it. But it's still working out either way and can be much easier to setup/maintain in some cases. (And probably falls into the "shared libraries as extension system" category Linus excluded from his commentary.)

Re:“Shared libraries are not a good thing in general” by OnlyOneCannolo on Saturday May 01, 2021 @10:37PM (#27011908)
That's part of it, which I agree falls under the excluded category. I was thinking more about code generation and program modification.

Curious what the better way to swap implementations would be?

Re:“Shared libraries are not a good thing in general” by OnlyOneCannolo on Saturday May 01, 2021 @10:11PM (#27011794)
I should clarify - it's at the start of runtime when the library is initially loaded. Not afterwards. You'd have to restart the program to swap a library.

For testing and simulation, it's a way to mock dependencies. You get to test the otherwise exact binary you'll deploy. And you can inject tracing and logging.

Solver installations tend to be long-lived, but require customizations, upgrades, and fixes over time. Dynamic linking lets you do that without going through the pain of reinstalling it every time. Also with solvers you're likely to see unconventional stuff for performance or even just due to age.

Re:“Shared libraries are not a good thing in general” by ofrzeta on Sunday May 02, 2021 @02:08AM (#27012716)
> ... when the library is initially loaded. Not afterwards. You'd have to restart the program to swap a library.

When you close the library with dlclose() you can swap it during runtime, too.

Re:“Shared libraries are not a good thing in general” by duped on Sunday May 02, 2021 @10:49AM (#27015761)
Dependency injection is useful for mock testing in C/C++ although there are more programmatic ways to do it for the latter