For completeness, the Opt Size binary on Rust is compiled with the --release 
option, with the following parameters in Cargo.toml: 
    
    
    [profile.release]
    opt-level = 'z'  # Optimize for size.
    lto = true # Enable linke time optimization
    codegen-units = 1
    panic = 'abort'
    
    
    Run

The rust binary started out comparable with a 'Hello World' application which 
is why I prototyped. After adding the simple-server module to the rust version, 
there was no competition. The Nim version uses the asynchttp module, and has 
euantoranos serial.nim for other functionality, the Rust version is just the 
functioning HTTP Server.

Inspecting both binaries with ldd, they seem to both be dynamically linked:

Rust Version: 
    
    
    ldd usbserver
            linux-vdso.so.1 (0x00007ffc1c1f7000)
            libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fc3a2704000)
            libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fc3a26e2000)
            libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fc3a26c8000)
            libc.so.6 => /usr/lib/libc.so.6 (0x00007fc3a2501000)
            /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 
(0x00007fc3a2885000)
    
    
    Run

Nim Version: 
    
    
    ldd main
            linux-vdso.so.1 (0x00007fff5dfe5000)
            libm.so.6 => /usr/lib/libm.so.6 (0x00007fddfd43c000)
            librt.so.1 => /usr/lib/librt.so.1 (0x00007fddfd431000)
            libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fddfd42c000)
            libc.so.6 => /usr/lib/libc.so.6 (0x00007fddfd265000)
            /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 
(0x00007fddfd6ab000)
            libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fddfd243000)
    
    
    Run

Rust pulls in pthread because simple-server is threaded by default, whereas 
asynchttp uses async methods. Which is another point, async/await support in 
Rust is very new, and seems (IMHO) to be very clunky when compared to 
async/await support in Nim.

Reply via email to