Created
November 14, 2018 12:45
-
-
Save kungtotte/07c9d16918653d2f8b6fc6894d93e01c to your computer and use it in GitHub Desktop.
Nim versus Rust binary sizes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fib_nim.nim: | |
proc fib(n: int32): int32 = | |
if n == 0 or n == 1: | |
return n | |
else: | |
return fib(n - 1) + fib(n - 2) | |
when isMainModule: | |
echo "Fib 15: ", fib(15) | |
echo "Fib 11: ", fib(11) | |
echo "Fib 19: ", fib(19) | |
fib_rust.rs: | |
fn main() { | |
println!("Fib 15: {}", fib(15)); | |
println!("Fib 11: {}", fib(11)); | |
println!("Fib 19: {}", fib(19)); | |
} | |
fn fib(n: i32) -> i32 { | |
if n == 0 || n == 1 { | |
return n | |
} else { | |
return fib(n - 1) + fib(n - 2) | |
} | |
} | |
% nim c fib_nim.nim | |
% rustc fib_rust.rs | |
% ls -l | |
.rwxr-xr-x 112k thomas 14 nov 13:41 fib_nim* | |
.rw-r--r-- 208 thomas 14 nov 13:36 fib_nim.nim | |
.rwxr-xr-x 4,0M thomas 14 nov 13:41 fib_rust* | |
.rw-r--r-- 253 thomas 30 okt 15:34 fib_rust.rs | |
% strip fib_nim | |
% strip fib_rust | |
% ls -l | |
.rwxr-xr-x 92k thomas 14 nov 13:42 fib_nim* | |
.rw-r--r-- 208 thomas 14 nov 13:36 fib_nim.nim | |
.rwxr-xr-x 424k thomas 14 nov 13:42 fib_rust* | |
.rw-r--r-- 253 thomas 30 okt 15:34 fib_rust.rs | |
% nim c -d:release --opt:size fib_nim.nim | |
% ls -l fib_nim | |
.rwxr-xr-x 48k thomas 14 nov 13:43 fib_nim* | |
% strip fib_nim | |
% ls l fib_nim | |
.rwxr-xr-x 35k thomas 14 nov 13:44 fib_nim* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On FreeBSD 12.0 with rustc rustc 1.37.0
An improvement but not near nim yet