Debunking the Java Performance Myth
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.<p>In Go on the other hand, doing simple &#x27;mistakes&#x27; like declaring a variable inside a loop can bring you to performance hell:<p>Declaration in a loop:<p><pre><code>        var sum int
        for i := 0; i &lt; n; i++ {
                x := i + i
                sum = x - i
        }
</code></pre>
Declaration outside the loop:<p><pre><code>        var sum int
        var x int
        for i := 0; i &lt; n; i++ {
                x = i + i
                sum = x - i
        }
</code></pre>
Benchmark results:<p><pre><code>  BenchmarkInLoop-8       2000000000               0.40 ns&#x2F;op
  BenchmarkOutLoop-8      2000000000               0.47 ns&#x2F;op
</code></pre>
And the same is certainly true for C&#x2F;C++.<p>Src: <a href="https:&#x2F;&#x2F;nopaste.xyz&#x2F;?68c6800acd9200d6#mDstI36uBPBU4Td8k&#x2F;&#x2F;GNC+P7mmbB1ldMw3DGMuxeQo=" rel="nofollow">https:&#x2F;&#x2F;nopaste.xyz&#x2F;?68c6800acd9200d6#mDstI36uBPBU4Td8k&#x2F;&#x2F;GNC...</a>