| language | size | size (desc) | flags |
|---|---|---|---|
| cpp/c++ | 10,752 | 10.5 KB | |
| nim | 140,008 | 136 KB | nim cpp -d:release --opt:size --out=hello_nim_cpp.exe hello.nim |
| nim | 185,955 | 181 KB | nim c -d:release --opt:size --out=hello_nim_c.exe hello.nim |
| d | 507,392 | 495 KB | dmd -O -release hello.d -of=hello_d_dmd.exe |
| d | 462,848 | 452 KB | ldc2 -O -release hello.d -of=hello_d_ldc_static.exe |
| d | 10,752 | 10.5 KB | ldc2 -O -release -link-defaultlib-shared hello.d -of=hello_d_ldc_dyn.exe |
| odin | 247,808 | 242 KB | odin build hello.odin -file -out:hello_odin.exe -o:size |
| go | 863,744 | 843 KB | go build -o hello_go.exe -ldflags="-s -w" hello.go |
| rust | 152,064 | 148 KB | cargo build --release |
package main
func main() {
// 注意,这里没有使用 fmt.Println可以减少文件大小
print("Hello, World!\n")
}编译命令
go build -o hello_go.exe -ldflags="-s -w" hello.go-
"-s -w"的解释
-
go build -ldflags="-help" hello.go
hello_go.exe 843 KB (863,744 字节)
#include <cstdio>
int main()
{
printf("Hello World!");
}msvc
cl /c /Zi /W3 /WX- /diagnostics:column /sdl /O2 /Oi /GL /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /permissive- /Fo"x64\Release\\" /Fd"x64\Release\vc143.pdb" /external:W3 /Gd /TP /showIncludes /FC /errorReport:prompt hello.cpplink.exe /ERRORREPORT:PROMPT /OUT:"x64\Release\hello.exe" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"x64\Release\hello.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG:incremental /LTCGOUT:"x64\Release\hello.iobj" /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"x64\Release\hello.lib" /MACHINE:X64 x64\Release\hello.obj10.5 KB (10,752 字节)
echo "Hello World!"nim c -d:release --opt:size --out=hello_nim_c.exe hello.nim
nim cpp -d:release --opt:size --out=hello_nim_cpp.exe hello.nim
- hello_nim_c.exe
- 181 KB (185,955 字节)
- hello_nim_cpp.exe
- 136 KB (140,008 字节)
package main
import "core:fmt"
main :: proc() {
fmt.println("Hello, World!")
}odin build hello.odin -file -out:hello_odin.exe -o:size
242 KB (247,808 字节)
fn main() {
println!("Hello, world!");
}cargo build --release
148 KB (152,064 字节)
import std.stdio;
void main() {
puts("Hello, World!");
}dmd -O -release hello.d -of=hello_d_dmd.exe
ldc2 -O -release hello.d -of=hello_d_ldc_static.exe
ldc2 -O -release -link-defaultlib-shared hello.d -of=hello_d_ldc_dyn.exe
- hello_d_dmd.exe
- 495 KB (507,392 字节)
- hello_d_ldc_static.exe
- 452 KB (462,848 字节)
- hello_d_ldc_dyn.exe
- 10.5 KB (10,752 字节)