4/3/2026 at 6:21:02 PM
Tinygo made a lot of progress over the years -- e.g. they've recently introduced macOS support!It does indeed produce much smaller binaries, including for macOS.
yuriy@MacBookAir ~/t/tinygo> time tinygo build -o test-tiny main.go
________________________________________________________
Executed in 1.06 secs fish external
usr time 1.18 secs 0.31 millis 1.18 secs
sys time 0.18 secs 1.50 millis 0.18 secs
yuriy@MacBookAir ~/t/tinygo> time go build -o test-normal main.go
________________________________________________________
Executed in 75.79 millis fish external
usr time 64.06 millis 0.41 millis 63.64 millis
sys time 96.76 millis 1.75 millis 95.01 millis
yuriy@MacBookAir ~/t/tinygo> ll
total 5096
-rw-r--r--@ 1 yuriy staff 74B 3 Apr 19:17 main.go
-rwxr-xr-x@ 1 yuriy staff 2.3M 3 Apr 19:18 test-normal*
-rwxr-xr-x@ 1 yuriy staff 192K 3 Apr 19:18 test-tiny*
yuriy@MacBookAir ~/t/tinygo> cat main.go
package main
import "fmt"
func main() {
fmt.Printf("Hello world!\n")
}
by nasretdinov
4/4/2026 at 4:12:31 PM
What does it look like if you pass -ldflags=“-s -w”?by maccard
4/4/2026 at 10:28:11 PM
With Go v1.26.1 package main
import "fmt"
func main() {
fmt.Printf("Hello World!\n")
}
Binary sizes:• 2581616B (2.5MB) → 1714560B (1.6MB) (with -ldflags="-s -w")
• 1531920B (1.5MB) → 753680B (0.7MB) (with upx --force-macos)
That said, a trivial “Hello World!” isn’t a meaningful benchmark. If you’re going to play that game, you might as well swap `fmt.Printf` for `fmt.Println`, or even `println` to avoid the import statement entirely. At that point, you’re no longer comparing anything interesting, the binaries end up roughly the same size anyway.
by guessmyname
4/5/2026 at 1:33:32 PM
I find it quite interesting that import of "fmt" package alone leads to a 2+ MiB binary :). But, to be fair, TinyGo doesn't seem to treat "fmt.Printf" function any differently from others, so it does compile the same source code as the regular Go compiler and just has better escape analysis, dead code elimination, etc.by nasretdinov