Hacker News new | ask | show | jobs
by brrt 2644 days ago
No horse in the race, but:

- The Rust compiler uses the LLVM backend, which is generally more aggressive about optimizations and code generation. The Go compiler is a custom compiler (I think plan 9 inherited) and as of fairly recently didn't do some optimizations that are fairly common otherwise (non-leaf inlining).

- Rust as a language heavily favors automatic (stack) allocation, and does not favor complex object graphs, so that will often help make algorithms more cache-friendly. In go, stack allocation is strictly an optimization. This is somewhat defeated by the common use of 'smart' pointer types.

- Due to using segmented stacks, the function prologue/epilogue is a bit more involved in go, than it is in a language like rust.

So with rust, it is - with some work - possible to have code that executes as the equivalent C code would. I guess in go you could too, but it'd be quite a bit harder, and go against the grain of the language.

Compared to the performance of a typical interpreted dynamic language, this is a fairly marginal difference however.