4 ms·
I wrote go-like because I think of C#/.NET and go as somewhat comparable and I'm not aware of any other language in a similar class that produces statically-lin
by math 11y ago
I wrote go-like because I think of C#/.NET and go as somewhat comparable and I'm not aware of any other language in a similar class that produces statically-linked binaries. However I'm pretty ignorant, so would not be surprised if there are many ... examples?
- pjmlp 11y agoAny programming language that has AOT compilation to native code among its implementation choices. There are plenty to choose from, but if you want a list: PL/I, Algol, PL/M, Quick Basic, Turbo Basic, Quick Pascal, Turbo Pascal, C, C++, Ada, Eiffel, Haskell, Objective-C, OCaml, Delphi, Oberon, Oberon-2, Component Pascal, Mesa, Modula-2, Modula-2+, Modula-3,...
- qwertyuiop924 11y agoDo all of those support static linking with the default tooling? (That is to say, not just hypothetical support, but actual support) Jeez.
- pjmlp 11y agoOf course, once upon a time static linking was the only way. It is dynamic linking that is hard to implement, not the other way around.
- qwertyuiop924 11y agoI KNOW that. I just wanted to know if the native compilers for the languages you mentioned supported static compilation either through a switch or by default, or if it's something that somebody else would have to write.
- pjmlp 11y agoInitially by default, many of them are older than OSes with dynamic linking support. The ones with compilers that also support dynamic linking, either via a switch or via explicit dynamic modules.
- pjc50 11y agoC and C++ will produce statically linked binaries if you ask nicely (gcc -static). There are some traps though; one I ran into for example is that you require dynamic linking in order to use libnss. I ended up producing a mostly-static binary that just depended on the platform's libc but brought its own libstdc++. Similarly on Windows, statically linking third-party COM components is not a good idea.
- ptx 11y agoI recently rediscovered (lying around on my disk) a bunch of Free Pascal[0] programs that I wrote and compiled in 1999. The executables are all statically linked and still run just fine on my current Linux system. The simple "hello world"-eque ones take up just tens of kilobytes of space. [0] http://freepascal.org/ http://freepascal.org/