Skip to content

Instantly share code, notes, and snippets.

@whiteinge
Last active May 11, 2024 16:36
Show Gist options
  • Save whiteinge/662e8cd1d361003b34531d9ee3c94197 to your computer and use it in GitHub Desktop.
Save whiteinge/662e8cd1d361003b34531d9ee3c94197 to your computer and use it in GitHub Desktop.
File sizes for "hello world" in various comple-to-C and compile-to-binary languages
Default compiler settings used, unless noted otherwise. Host system is Fedora
x86_64. Linked libs produced via `ldd`.
Linked libs common to all below: linux-vdso libc ld-linux
Size Lang Specific libs Common libs
18K c - -
20K luastatic liblua libm libdl
22K vala libgobject libglib libffi libpcre libpthread
27K urweb liburweb_http liburweb libm libcrypto libssl libpthread libz libdl
31K dlang (ldc2) libphobos2-ldc-shared libdruntime-ldc-shared libm libgcc_s libc
31K vlang (-prod) - libm libpthread libdl
32K ada libgnat libdl libm libgcc_s
34K chicken libchicken libm libdl
36K kit - libm
37K dlang (gdc) libgphobos libgcc_s libm libc
41K C++ - libstdc++ libm libgcc
56K ecl libecl libgmp libgc libffi libpthread libdl libm libatomic_ops libgcc_s
70K zig (ReleaseSmall) - (not dynamic)
70K idris - libgmp libpthread libm
83K red libRedRT linux-gate libm libpthread libgdk_pixbuf-2.0 libcurl libgtk-3 libudev libglib libgobject libgmodule libgio libpng16 libjpeg libnghttp2 libidn2 libssh libpsl libssl libcrypto libgssapi_krb5 libldap liblber libbrotlidec libz libgdk-3 libpangocairo-1.0 libpango-1.0 libharfbuzz libcairo libpangoft2-1.0 libfontconfig libfribidi libcairo-gobject libatk-1.0 libepoxy libXi libX11 libatk-bridge-2.0 libcloudproviders libtracker-sparql-3.0 libwayland-client libXfixes libcap libgcc_s libpcre2-8 libffi libmount libselinux libunistring libkrb5 libk5crypto libcom_err libkrb5support libkeyutils libresolv libevent-2.1 libsasl2 libbrotlicommon libxkbcommon libwayland-cursor libwayland-egl libXext libXcursor libXdamage libXcomposite libXrandr libXinerama libthai libfreetype libgraphite2 libXrender libxcb libxcb-render libxcb-shm libpixman-1 libxml2 libatspi libdbus-1 libjson-glib-1.0 libsqlite3 libblkid libcrypt libdatrie libbz2 libXau liblzma libsystemd libzstd liblz4
92K polyml libpolyml libstdc++ libm libgcc_s libpthread libffi libgmp libdl
175K vlang - libm libpthread libdl
177K cakeml - -
208K mlton - libm libgmp
320K ocaml - libm libdl
374K rust - libgcc_s
549K nim - libdl
569K zig - (not dynamic)
594K janet - libm libdl librt libpthread
840K dlang (dmd) - libpthread libm librt libdl libgcc_s
1.2M mlton (static) - (not dynamic)
1.9M golang - (not dynamic)
2.1M chicken ("static") - libm libdl
2.6M roc - (not dynamic)
2.7M haskell - libm libgmp librt libdl libpthread
9.7M sbcl (compressed) - libdl libpthread libz libm
12M racket 8 (raco exe) - libpthread
38M sbcl - libdl libpthread libz libm
42M node-pkg - libdl librt libstdc++ libm libgcc_s libpthread
45M node-nexe - libdl libstdc++ libm libgcc_s libpthread
@whiteinge
Copy link
Author

Cool. Thanks for the addition. What system did you build those results on?

@Imperatorn
Copy link

Imperatorn commented Sep 28, 2023

Try a D hello world

[1] ldc2 -O -release -link-defaultlib-shared -betterC app.d // using extern(C)
[2] ldc2 -O -release -link-defaultlib-shared app.d // normal

dlang.org - LDC

import std.stdio : printf;

void main()
{
    printf("Hello world");
}

vs betterC

import core.stdc.stdio;

extern(C) void main()
{
    printf("Hello world");
}

I got it to 9-10k

@whiteinge
Copy link
Author

Very interesting. The different D compilers have pretty different file size and linked lib results. Updated. Thanks for the comment!

@Imperatorn
Copy link

Very interesting. The different D compilers have pretty different file size and linked lib results. Updated. Thanks for the comment!

You're welcome 😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment