Last active
September 17, 2024 06:41
-
-
Save flymanzhao/e0ded3b0cacf47babab85a95a56dcae3 to your computer and use it in GitHub Desktop.
Revisions
-
flymanzhao revised this gist
Sep 17, 2024 . No changes.There are no files selected for viewing
-
flymanzhao revised this gist
Sep 17, 2024 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -8,9 +8,9 @@ | 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 | ## go -
flymanzhao revised this gist
Sep 17, 2024 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,18 @@ # 编译到Native的语言HelloWorld二进制大小 | 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 | | | go | 863,744 | 843 KB | | | rust | 152,064 | 148 KB | | ## go ### code -
flymanzhao revised this gist
Sep 17, 2024 . 1 changed file with 32 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # 编译到Native的语言HelloWorld二进制大小 ## go ### code @@ -133,4 +135,33 @@ cargo build --release ### result 148 KB (152,064 字节) ## D ### code ```D import std.stdio; void main() { puts("Hello, World!"); } ``` ### compile cmd ```` 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 ```` ### result - 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 字节) -
flymanzhao revised this gist
Sep 17, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,7 @@ hello_go.exe 843 KB (863,744 字节) ## cpp/c++ ### code ````c++ #include <cstdio> -
flymanzhao renamed this gist
Sep 17, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
flymanzhao created this gist
Sep 17, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,136 @@ ## go ### code ```go package main func main() { // 注意,这里没有使用 fmt.Println可以减少文件大小 print("Hello, World!\n") } ``` ### compile cmd 编译命令 ```bash go build -o hello_go.exe -ldflags="-s -w" hello.go ``` - "-s -w"的解释 - https://pkg.go.dev/cmd/link - ```bash go build -ldflags="-help" hello.go ``` ### result hello_go.exe 843 KB (863,744 字节) ## cpp/c++ ### code ````c++ #include <cstdio> int main() { printf("Hello World!"); } ```` ### compile cmd msvc ```bash 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.cpp ``` ```bash link.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.obj ``` ### result 10.5 KB (10,752 字节) ## nim ### code ```nim echo "Hello World!" ``` ### compile cmd ``` 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 ``` ### result - hello_nim_c.exe - 181 KB (185,955 字节) - hello_nim_cpp.exe - 136 KB (140,008 字节) ## Odin ### code ````go package main import "core:fmt" main :: proc() { fmt.println("Hello, World!") } ```` ### compile cmd `odin build hello.odin -file -out:hello_odin.exe -o:size` ### result 242 KB (247,808 字节) ## Rust ### code ```rust fn main() { println!("Hello, world!"); } ``` ### compile cmd ``` cargo build --release ``` ### result 148 KB (152,064 字节)