Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?


C 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.


Any 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,...


Do all of those support static linking with the default tooling? (That is to say, not just hypothetical support, but actual support)

Jeez.


Of 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.


I 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.


Initially 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.


I 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/




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: