by josephg · 3y ago · 0 comments
Why would the performance of these languages be identical? These languages aren’t the same in lots of ways.
Golang has a GC and gives you much less control over memory layout than any of the other languages you mentioned. It also has a very different concurrency model, which will vastly change the performance characteristics of multithreaded code.
Rust is limited to llvm, while C can be compiled with many other compilers - some of which produce better code in many cases. (Eg icc)
Rust has much better noalias analysis - which allows the compiler to make optimizations that aren’t available in general purpose C or C++ code. (Since nobody adds noalias to all their variables in C, for a variety of reasons).
Unlike the others, C doesn’t support monomorphization (without disgusting macro tricks). Monomorphization cuts both ways with performance - since it bloats executables (and thus hurts the branch predictor and cache) while generating more efficient code.
These languages aren’t the same. There’s lots of reasons they will perform differently both at the limits of what we can optimize and in the average case of everyday code. It’s wild that you would consider them to all be the same.
There's a rust front-end for gcc as well.
Doesn’t the borrow checker also track when things fall out of scope, and thus control when Drop is called?