3 ms·
Definitely agree. Another example of lost performance that comes to mind is (ignorance of) C struct padding. In terms of modern tools, Rust has definitely made
by Svetlitski 5y ago
Definitely agree. Another example of lost performance that comes to mind is (ignorance of) C struct padding. In terms of modern tools, Rust has definitely made some headway here:
• Variables are immutable by default
• The layout of a struct’s fields in memory is opaque to the programmer, allowing the compiler to reorder them to minimize padding
• As a natural consequence of the borrow checker, Rust has much more information about whether or not two references could alias than most other languages
• The programmer is very much made to feel the cost of dynamic-dispatch (via dyn), and static-dispatch is the norm
• The compiler can omit bounds checks when it can prove they’re unnecessary
• It’s easy to safely have structs that live entirely on the stack (i.e. no heap allocation)
Overall this is an unsolved problem though. It seems to me that the trend is that the more details about the internals that the language exposes to the programmer, the fewer optimizations can be made automatically. Essentially the ideal is declarative performance, where the programmer expresses the idea and the compiler figures out the optimal implementation (which is in stark contrast to most high-performance code being hand-tuned today). Take a look at something like Halide for a successful application of this philosophy: https://halide-lang.org/ https://halide-lang.org/