this post was submitted on 07 Sep 2023
64 points (97.1% liked)

Programming

17417 readers
84 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 

There was a time where this debate was bigger. It seems the world has shifted towards architectures and tooling that does not allow dynamic linking or makes it harder. This compromise makes it easier for the maintainers of the tools / languages, but does take away choice from the user / developer. But maybe that's not important? What are your thoughts?

you are viewing a single comment's thread
view the rest of the comments
[–] ono@lemmy.ca 15 points 1 year ago* (last edited 1 year ago) (3 children)

Shared libraries save RAM.

Dynamic linking allows working around problematic libraries, or even adding functionality, if the app developer can't or won't.

Static linking makes sense sometimes, but not all the time.

[–] robinm@programming.dev 4 points 1 year ago (1 children)

Shared libraries save RAM.

Citation needed :) I was surprised but I read (sorry I can't find the source again) that in most cases dynamic linking are loaded 1 time, and usually very few times. This make RAM gain much less obvious. In addition static linking allows inlining which itself allow aggressive constant propagation and dead code elimination, in addition to LTO. All of this decrease the binary size sometimes in non negligeable ways.

[–] ono@lemmy.ca 2 points 1 year ago (1 children)

I was surprised but I read (sorry I can’t find the source again) that in most cases dynamic linking are loaded 1 time, and usually very few times.

That is easily disproved on my system by cat /proc/*/maps .

[–] robinm@programming.dev 3 points 1 year ago (1 children)

Someone found the link to the article I was thinking about.

[–] ono@lemmy.ca 4 points 1 year ago* (last edited 1 year ago)

Ah, yes, I think I read Drew's post a few years ago. The message I take away from it is not that dynamic linking is without benefits, but merely that static linking isn't the end of the world (on systems like his).

[–] uis@lemmy.world 1 points 1 year ago

Not exactly, shared libraries save cache.

[–] cyclohexane@lemmy.ml 1 points 1 year ago (1 children)

if the app developer can't or won't

Does this apply if the app is open source?

[–] ck_@discuss.tchncs.de 1 points 1 year ago* (last edited 1 year ago)

In practical terms often yes. It can be easier in practical terms to just LD_PRELOAD something than to maintain your own patched version of an RPM / APT package for example.