Michael Wojcik said:
And your point?
My point is that a good programmer should not refuse to use a
perfectly useful OS facility on the grounds that poor programmers
misuse that facility. Dynamic linking is not somehow contaminated by
others' misuse of it. Idiots should avoid it, but then they should
avoid creating programs for others' consumption at all. There is no
need for non-idiots to avoid it.
Not so. Just fix the bug and ship the executable, which is no harder than
fixing the bug and shipping the DLL.
I am tempted to quote Dan Pop.
If a library is used by only one executable, why make it a library?
If it is used by more than one executable, then a fix to the library
requires shipping fixed versions of all executables, if it's
statically linked.
Yep, that strategy works for me. In any case, the analogy is flawed. In your
home, space is at a premium (unless you are extremely wealthy), whereas
disk space and computer memory are relatively cheap.
This argument is common (indeed, nearly universal) among the opponents
of dynamic linking, but it is entirely specious. On a typical modern
general-purpose OS, replacing all the dynamically-linked code with
statically-linked code would present a resource cost far in excess of
the "relative cheapness" of disk space and memory.
On one machine here in front of me, running Windows XP Pro, I
currently have 68 userspace processes running. 2192 DLLs are loaded
by them, from 358 distinct images, so on average an image is reused 6
times. The Windows loader isn't particularly smart, and is unable to
share an in- memory image if it's relocated; but I have only 58
relocations among those 2192, so the relocation rate is less than 3%.
The average size of a loaded DLL is 558 KB. So if we assume an even
distribution[1], the memory cost for DLLs on this system right now is
something like 358 * 1.03 * 558 KB = 200 MB. If they were statically
linked instead, the cost would be something like 2192 * 558 KB = 1194
MB, or about six times as much. I don't care to buy six times as
much RAM as I currently have installed, thank you very much. And the
disk space cost is worse.
There may be good arguments against dynamic linking, but I haven't
heard any yet from the proponents of static linking. I argued this
in the letters column of DDJ some years ago, and I've argued it since
on Usenet, and all I ever hear from the anti-dynamic camp is
"versioning is hard!" and "many dynamic libraries are bad!". The
latter is true, and the former is debatable; but they say nothing
about dynamic linking as a technology. Using them as an excuse to
reject dynamic linking is to succumb to guilt by association.
Ironically, it's the same logic that motivates most tirades against C
itself.
[1] That assumption is obviously unwarranted, but the point of this
simplistic analysis is that even a back-of-the-envelope estimate
suggests the "cheap memory" argument doesn't hold, which puts the
burden of more sophisticated analysis on those who advance such an
argument.
--
Michael Wojcik (e-mail address removed)
However, we maintain that our mission is more than creating high-tech
amusement--rather, we must endeavor to provide high-tech, high-touch
entertainment with an emphasis on enkindling human warmth.
-- "The Ultimate in Entertainment", from the president of video game
producer Namco