Go is generally faster than interpreted languages like Python and Ruby, and comparable to or slightly slower than C++ in raw execution speed, while offering significantly faster compilation times than C++.
// Benchmark comparison: Go vs Python (simple loop)
// go run -bench=. main.go
// python3 -m timeit -s "import time" "sum(range(10**7))"
package main
import (
"testing"
)
func BenchmarkGoLoop(b *testing.B) {
var sum int
for i := 0; i < b.N; i++ {
for j := 0; j < 10000000; j++ {
sum += j
}
}
}
Go achieves this performance through static typing, a garbage collector tuned for low latency, and a compiler that generates native machine code without a virtual machine overhead.