Ask HN: What languages produce self contained binaries?

4 points by abhijat ↗ HN
Go is one, are there any other languages which produce self contained binaries out of the box?

Or link dynamically but only to very few libraries like glibc so they are easy to distribute?

8 comments

[ 3.5 ms ] story [ 29.0 ms ] thread
Delphi/FreePascal
C, C++, D, Nim, Haskell, OCaml, Rust, Swift, Objective-C, Crystal..... the list goes on. Many of the languages have a native code implementation in addition to an interpreter or a byte code compiler — e.g. Common Lisp (SBCL), Scheme (Chicken Scheme), Kotlin/Native.....
I was looking for languages which produce binaries which are self contained (in terms of being statically linked OR dynamically linked with few dependencies) close to what go produces, out of a default build process.

I guess with musl C, C++ and Rust can do that though it is a bit of work.

OCaml seems to link only to non OCaml stuff dynamically, which fits the bill too.

Why does default build process matter? Once you haven figured it out and automated it (say, using a makefile), it doesn’t matter whether you’re using a default build process or not.

Also, the likes of Haskell let you build binaries dependent only on OS provided libraries whereas the likes of Nim compile to C. You might want to play with the short listed languages to get an idea. A simple Hello World will tell you what they link with by default. Anything beyond that is up to you.

I was actually wondering with all these new languages like zig, Odin and v are there any that produce dependency free binaries.

I've done some work in rust, c++, and nim before. But looking at some of the comments here and rethinking the pros and cons it seems a fully self contained binary might be more trouble than it's worth and some dependency is fine as long as an easy to use packaging and deployment process is found.

Sorry the question was a bit vague. I don't think I explained well what I was looking for.

Link dynamically if you care about security upgrades.
I was looking to distribute small cli tools easily.

I guess packaging them through the relevant package manager is a better option from a security perspective as opposed to a big static binary.

Yes, especially if you depend on security critical libraries like OpenSSL that might require urgent updates.