Giancarlo Bellido wrote:
> I don't know that much about compilers, and I've been wondering why is
> the linker necessary. Is it really necessary
I like to say (just because it's fun) that "The C linker is the Root of
All Evil." Being compatible with it leads to hacked C++ template
support. Most C++ programmers know about name mangling. Optimization
across files still generally sucks (there are some fairly new compilers
that globally optimize).
The reason for the linker is mainly historical. Back in high school, I
had a job programming a PDP-11/45. It had a whopping 128K of core
memory (actual magnetic cores used for each bit). We shared it between
8 users at a time. My max memory allocation was 16K bytes.
The compilers had to run off disk, in little pieces. We had "4 pass
compilers", which were slower than "3 pass compilers." That meant that
the source code had to be read 3 times instead of 4, which was the
bottleneck in compilation speed.
After creating all the obect files, the linker ran. That was always
fun. We had these washing machine sized hard disks, and the linker
sensitized an oscillation mode. Whenever we linked, one of these huge
things would rock back and forth making a terrible niose, and then start
walking around the room!
I guess I haven't been fond of linkers ever since.