Live data from Hacker News

An alternative to shared libraries

kix.in

11–20 of 24 posts

Re: An alternative to shared libraries

#11
"In summary, the answer is to write lean, efficient and small pieces of code..."

What if the user could avoid "non trivial" programs, i.e. the ones that purportedly make it impossible to avoid shared libraries?

To put it another way, what if a user could have a system containing only trivial programs that each do one thing and then use them in combination to do "complex" tasks?

The term "non trivial software" is one I see continuously used as an underlying assumption and hence a justification for maintaining the status quo of all manner of existing software problems.

I do not want more "non trivial" software. I want simplicity and reliability. Not to mention comprehensibility. I get those things from so-called "trivial" software.

When some the "non trivial software" I am forced to use becomes too reliant on too much resources or too many dependencies, I stop using it and find an alternative.

This strategy has worked beautifully for me over the years.

Shared libraries was a useful concept in its day.

In my humble opinion, those days have passed. GB of memory is more than enough for me personally.

I like to use crunched binaries in my systems. As such, I do not seek out "non-trivial" software and am always looking to eliminate any existing dependencies on it.

Re: An alternative to shared libraries

#12

What fascinates me is how close this synthetic filesystem is to making REST calls with a small client library. All your application needs to know is the path to call and what HTTP verb to use. Even the way the author introduces versioning sounds familiar: using a versioning file is similar to having a version at the beginning of your URL. I appreciate how good architectures all resemble each other at some point, with…

REST is just CRUD over HTTP. The file interface and Unix everything-is-a-file concept are one of the earliest well-defined CRUD interfaces in computing. The author (and Plan 9) are taking these concepts to their logical conclusion.

Re: An alternative to shared libraries

#13
post #11

"In summary, the answer is to write lean, efficient and small pieces of code..." What if the user could avoid "non trivial" programs, i.e. the ones that purportedly make it impossible to avoid shared libraries? To put it another way, what if a user could have a system containing only trivial programs that each do one thing and then use them in combination to do "complex" tasks? The term "non trivial software" is one…

Web browser is an extremelly non-trivial program and still I am assured we both use it.

Re: An alternative to shared libraries

#14
My experience from Windows is that DLL's are both blessing and pain. I'll give a concrete example, a not so small Qt application.

If you use the DLL version of Qt you get the following benefits:

  - Faster link time (More on this later). This is the big winner.

  - Minor-versions can be updated apart from the executables or other DLL's using it. This requires the library itself to be well written and respect that (Qt follows good procedures, sqlite is awesome example, but there are some terrible ones - like the P4 C++ api which constantly adds/removes virtual members, enums, etc.)

  - Fully optimized (/LTCG) dlls, if Qt allows to mix all in one DLL then even better (calls between QtCore and QtGui could be further reduced, code inlined, etc.). Okay you don't get full whole app (only full static link would do), but you get still good link times with overall good optimization.

  - Exceptions kept there, not propagated (controversial whether this is a good idea, but I like it).

  - No clashes with other (usually) statically linked libraries - like png, zlib, etc. Unless you really want both QtCore and your app to use exactly the same versions (for one reason or another).

  - Smaller executable size (this does not matter lately, but may come)

Minuses of DLL, pluses of static linking:

  - Deployment madness no more. You push one executable, everyone is happy. You don't need to make sure that pushed DLLs (.so) won't break other executables. You might be able to rollback or work on specific version if things go badly (this could be also done with Dlls', .so, but they have to reside along with the executable).

  - Somewhat faster execution time (less time to resolve symbols, load DLLs, etc.)

  - You get RTTI, exceptions, and in older versions of certain systems __declspec(thread) and other things working correctly.

  - Real full whole code optimization. But you should have other release targets (for development).

My biggest pain with DLLs (and executables) was on Windows where people would sync directly from P4 (perforce) and ran directly the executables from where they were synced (this way, there is no extra step - "Press or Run this thing after syncing"). But this comes with price - on Windows you can't replace running executable with another (or DLL). I've tried the various hacks where you set the executable/dll to be loaded from the NET or CD so that it's fully put in the swap, but still does not work. A correct way seems to be a proper deployment - you sync, you ran some kind of "Deployment" tool and then work.

From Windows point of view I really liked the idea of loading the DLL by first looking at your executable path, then for other places. Seems like UNIX is not this way, but then on UNIX people had stabilized places and locations for things (/usr/lib, /usr/local/lib, etc.).

Another problem is if you want to have simulatenously 32-bit and 64-bit dlls/.so. I like OSX's solution most of fat binaries, but seems like Linux folks do not like that (there was a proposal time ago), and on Windows that's out of the question.

It doesn't scale really when you get more architectures/models, but if you have mainly 2 it might work pretty well (apart from being pain for the build system).

Re: An alternative to shared libraries

#15
post #11

"In summary, the answer is to write lean, efficient and small pieces of code..." What if the user could avoid "non trivial" programs, i.e. the ones that purportedly make it impossible to avoid shared libraries? To put it another way, what if a user could have a system containing only trivial programs that each do one thing and then use them in combination to do "complex" tasks? The term "non trivial software" is one…

Web browser is an extremelly non-trivial program and still I am assured we both use it.

Not all of them. Some folks still browse the web via Emacs, Lynx, and Surf - all rather simplistic browsers which work fine for a large number of sites, including this one.

Re: An alternative to shared libraries

#16
post #14

My experience from Windows is that DLL's are both blessing and pain. I'll give a concrete example, a not so small Qt application. If you use the DLL version of Qt you get the following benefits: - Faster link time (More on this later). This is the big winner. - Minor-versions can be updated apart from the executables or other DLL's using it. This requires the library itself to be well written and respect that (Qt fol…

Regarding deployment via a single executable: that's only true if your application consists solely of code (or resources which can be deployed in code, such as XBMs). As soon as you start having resources which aren't code, you end up having to deploy them as well, which means you have to start versioning them, etc, etc. The version of Chrome I'm typing this into is 120 files, one of which is the executable.

Regarding faster execution time: that's debatable. You certainly won't necessarily get faster application startup, because you're going to have to page in all that code, where with a DLL it's probably already in memory and used by another process. You're also likely to use a lot more memory, because each process will have its own Qt instance, and they won't be shareable.

Re RTTI and exceptions: works for me on Linux! Does this really not work on Windows?

Re whole code optimisation: that I'll grant you. And DLL code is typically terrible (because of hacks needed to allow text pages to be shared between processes).

Re: An alternative to shared libraries

#17
post #4

An excellent read. Moreover, most linkers these days have the ability to strip out unused code from your executable if you are using static linkage. That means if your tiny executable uses just some methods of a gigantic library, it can do so an it will still stay tiny. Contrast that with dynamic linkage where in practice the whole gigantic library has to ship with your executable because you can never be sure that t…

> if your tiny executable uses just some methods of a gigantic library, it can do so an it will still stay tiny How many other functions do the ones you explicitly call drag into the executable? How do you propose to deduplicate them and their resources between processes? I'm specifically thinking about UI code. Having 30 different copies of your UI toolkit and its resources would be silly, even if each was stripped…

The X Window System architecture solves a specific problem - allowing clients to use graphical applications no matter where the app actually runs. This was important in the 1980s and is still worthwhile today - no matter how much compute power you can stash under your desk or wear on your wrist, you can cram orders of magnitudes more into a data center. Having a uniform interface that's independent of where the heavy lifting actually happens is a crucial accomplishment for X, and throwing that away with the focus on Direct X is ultimately a mistake.

Re: An alternative to shared libraries

#18

Earlier quoted context omitted.

Web browser is an extremelly non-trivial program and still I am assured we both use it.

Not all of them. Some folks still browse the web via Emacs, Lynx, and Surf - all rather simplistic browsers which work fine for a large number of sites, including this one.

[deleted]

Re: An alternative to shared libraries

#19

Earlier quoted context omitted.

Web browser is an extremelly non-trivial program and still I am assured we both use it.

Not all of them. Some folks still browse the web via Emacs, Lynx, and Surf - all rather simplistic browsers which work fine for a large number of sites, including this one.

Isn't Lynx 175,000 lines of code?

Re: An alternative to shared libraries

#20

Earlier quoted context omitted.

Web browser is an extremelly non-trivial program and still I am assured we both use it.

Not all of them. Some folks still browse the web via Emacs, Lynx, and Surf - all rather simplistic browsers which work fine for a large number of sites, including this one.

Simplistic, but not non-trivial. Neither of them use curl-the-binary for http requests, I think.
Post reply on HN