This question already has an answer here:
- Reason for huge size of compiled executable of Go 3 answers
- How to reduce compiled file size? 11 answers
I tried Go tonight, and upon building a very simple program I noticed the file size of the executable was much larger than it would be in C.
A simple hello world program in Go is 1.5mb after being built:
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
And here it is in C, which is much smaller at 4.9kb
#include <stdio.h>
int main(int argc, char** argv)
{
printf("Hello World
");
return 1;
}
Why the large size difference if both are being compiled to machine code?
Edit: I am not asking how to reduce the size of the executable, I am asking why it's larger.
</div>