3 ms·
Linking was also invented because sources to certain libraries were (and often still are) closed, not available at compile time. Another point of linking is, w
by nine_k 5y ago
Linking was also invented because sources to certain libraries were (and often still are) closed, not available at compile time.
Another point of linking is, well, linking together different source languages, often a high-level language and and assembly, or a high-level language and C. In certain areas, libraries written in Fortran are important, too.
A complete language monoculture often is not attainable, even with languages as total as C++, Rust, or Java.
- pjmlp 5y agoStill in some languages like Turbo Pascal, the linker was part of the compiler, so there was no separate linking step.
- andrewshadura 5y agoIt was built-in and called automatically, but since version 4.0 if I remember correctly linking was indeed a separate step. Units were each compiled into TPUs (or, later, DCUs) and then linked together, possibly with external OBJs.
- pjmlp 5y agoYou could do it both ways, there was tlink.exe for script based builds, but also included in the compiler on the IDE, then again maybe I need to go have a look at those old manuals.
- pjmlp 5y agoI did recall it correctly, > Turbo Pascal's built-in linker automatically removes unused code and data when building an .EXE file. Turbo Pascal 6.0 Programmers' Guide page 258.
- junon 5y ago> Linking was also invented because . . . This is just plain wrong. Linking was, and still is, about assembling a final executable in a format and a way that accurately describes the data within it. For example, kernels tend to need very customized linker scripts in order to place all of the data in the correct spots. The reason why linking can be hidden in most cases is because building an executable for a specific system is generally straightforward and well specified, needing little to no tweaking or opinions about how it's built. This is not always the case, and linking was certainly not "invented" to work around binaries with no sources...
- nine_k 5y agoTheoretically, the compiler can form a complete "statically-linked" executable, and even sidestep libc to use kernel APIs. Golang tends towards this. This may diminish if not eliminate the role of linking. The case of VM-based languages is entirely out of purview of the system linker, too.
- titzer 5y ago> Theoretically, the compiler can form a complete "statically-linked" executable, and even sidestep libc to use kernel APIs. This isn't theoretical, it's exactly how Virgil generates binaries for x86-darwin, x86-linux, and x86-64-linux. The output is just one binary and no C environment. No C libraries for anything. Instead, the Virgil compiler knows the kernel ABI for the target and library code (written in Virgil) implements a thin portable layer directly in terms of syscalls using raw pointers.
- junon 5y agoAgain, that's if the compiler is the only thing contributing object code to the final executable...