Well, I have not taken a look at the implementation yet, but java is certainly known for delivering a decent performance even if the programmer is a little careless regarding perfromance.
In Go on the other hand, doing simple 'mistakes' like declaring a variable inside a loop can bring you to performance hell:
Declaration in a loop:
var sum int
for i := 0; i < n; i++ {
x := i + i
sum = x - i
}
Declaration outside the loop: var sum int
var x int
for i := 0; i < n; i++ {
x = i + i
sum = x - i
}
Benchmark results: BenchmarkInLoop-8 2000000000 0.40 ns/op
BenchmarkOutLoop-8 2000000000 0.47 ns/op
And the same is certainly true for C/C++.Src: https://nopaste.xyz/?68c6800acd9200d6#mDstI36uBPBU4Td8k//GNC...