2

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\n");
    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.

BugHunterUK
  • 8,346
  • 16
  • 65
  • 121

0 Answers0