5 ms·
I agree with some of your points; but zero-reliance on libc is the reason why it's so easy to use Go in containers; and Docker is one of the primary reasons why
by krasin 7y ago
I agree with some of your points; but zero-reliance on libc is the reason why it's so easy to use Go in containers; and Docker is one of the primary reasons why Go is popular. It's what they have got right.
- Skunkleton 7y agoYou could statically link in libc and get the same effect.
- IshKebab 7y agoSays someone who has never actually tried to do that. You can statically link with Musl. But you can't really statically link with Glibc.
- josteink 7y agoTechnically speaking OP only suggested statically linking (a) libc, not glibc specifically, and musl is a libc.
- Skunkleton 7y agoNot sure what’s up with the combative tone? FWIW, I work as an operating systems developer. We sell several products incorporating a few in house libc variants. They are most certainly statically linked.
- saagarjha 7y agoYou can, it just might do some strange things when dealing with iconv.
- Spivak 7y agoStatically linking libc is it’s own minefield. It can and is done but even if you statically link everything else you should almost always dynamically link against your platform’s libc.
- paulddraper 7y agoStatically linking libc is harder than dynamically linking it, but certainly easier than rewriting it.
- yencabulator 7y agoGood thing we don't want to use much of libc functionality from Go, so nobody needs to reimplement all of it. It's not like people would be begging to call strcpy. All that's needed is the syscalls.
- saagarjha 7y agoWhy? I see no reason you couldn’t on platforms with a stable syscall ABI, other than the standard reasons against static linking.
- thu2111 7y agoIt depends on the libc. glibc doesn't really "want" to be statically linked. It can be done sometimes, depending on how it's used, the phase of the moon and so on, but breaks from time to time until it's repaired. Some of the issues are fundamental. For instance the dynamic linker is a part of the C libraries. If you statically link libc and then dynamically load another shared library, you can end up with two copies of the C libraries loaded at once. The C library expects various external files to be found on disk, in a format that isn't totally forwards/backwards compatible. That's reasonable when things are dynamically linked because the linker and C library abstract the developer from format changes. If you statically link you should really statically link the data files too, but the C toolchain has no provision for that.
- pjmlp 7y agoThe ISO C standard library has no such expectations regarding external files.
- deleted 7y ago[deleted]
- labawi 7y agoYou'd still have to get a static libc (not usually preinstalled), possibly compile it for a different os/architecture..
- p_l 7y agoExcept glibc does not really support static linking of you want network support.
- pjmlp 7y agoglibc is just one possible ISO C implementation with lots of extra stuff on top.
- stqism 7y agoAn issue here is that statically linking against glibc is generally regarded as a poor idea and I’ve seen a couple non trivial programs that refuse to run with other libc’s.
- deleted 7y ago[deleted]
- rapsey 7y agoIf you want static linking use musl..
- y4mi 7y agoYou'd supposedly sacrifice performance though. At least that's the common complaint for Alpine docker images... It's based on musl and halve of the community always complains about serious performance degradation
- pjmlp 7y agoExcept that Docker was originally written in Java by the former team that actually started the project, and nowadays contains modules written in OCaml taken from the MirageOS project, for the macOS and Windows variants of Docker. So how much they got right regarding Docker's success and Go is a bit debatable.
- kjeetgill 7y agoI think the parent was reffering to using Go in Docker containers, not using Go for implementing Docker itself. That said, I agree that Docker was the first major project written in Go many people were exposed to and probably had some influence.
- kick 7y agoI'm just wondering, how is your line about the code taken from the MirageOS project relevant? Nobody uses the Windows and macOS variants of Docker in production.
- ffk 7y agoDocker was not written in Java. It was shell scripts, python, then go. Dotcloud was primarily a python shop. Perhaps you are thinking of a different project?
- michaelcampbell 7y ago> Docker is one of the primary reasons why Go is popular. Based on what data?
- twic 7y agoI've deployed all sorts of things which dynamically link libc in containers. This just isn't an issue in practice.