I know performance is important, but program size is too. Microcontroller-code is likely to be a niche for Nim, so every byte counts (within reason). Golang is known for bloated executables: https://donatstudios.com/Golang-Binary-Sizes
On my Mac, the minimum do-nothing go program is 900kB. On WIndows, it can be 8MB. (This is because several key libraries cannot be removed.) A do-nothing Nim program with -d:release is only 16044 bytes. C is about 1/3 of that without being fancy, but 16kB is low enough as libraries and useful code will dominate. In fact, this is small enough that binary executables could actually be included in repositories. There are many use-cases for small static binaries.
I thought people might like to hear some good news.
You can go down a bit further if you really want (at costs):
$ cat h.nim
echo "Hello World"
$ nim c h && ls -lha h
-rwxr-xr-x 1 def def 176K Mär 4 02:46 h*
$ nim -d:release c h && ls -lha h
-rwxr-xr-x 1 def def 57K Mär 4 02:46 h*
$ nim -d:release --opt:size c h && ls -lha h
-rwxr-xr-x 1 def def 25K Mär 4 02:47 h*
$ nim -d:release --opt:size c h && strip -s h && ls -lha h
-rwxr-xr-x 1 def def 19K Mär 4 02:48 h*
$ nim -d:release --opt:size c h && strip -s h && upx --best h && ls -lha h
-rwxr-xr-x 1 def def 11K Mär 4 02:48 h*
@def, it looks like your first 2 release builds are the same command, yet different sizes.
And upx is cheating IMO, but it's nice to seen lean executables :)
Indeed compiling to a standalone static executable, with a high level Pythonesque language, is a very compelling feature to me.
@def, it looks like your first 2 release builds are the same command, yet different sizes.
My bad, was missing a --opt:size.
We should mention that executable size may depend on c compiler, gcc may give much larger files than clang with lto, that executables on windows may be significantly larger, and that dynamic linkings works file also. See
I'll assume it's fine for Nim.
Yes, haven't had any problems with it. Except that I sometimes forget that I ran strip and why my symbols are gone when debugging.
BTW this question is only ever asked by Go proponents. ;-) The default is static linking against Nim's stdlib, dynamic linking against libc.
Afaict Go doesn't use libc (Nim doesn't use much of it either) so Go proponents came up with this rather meaningless "But other programs are just as big if they link statically" argument. Well, but nobody does that. :P
Static linking against GNU's libc is not allowed by its license anyway.