3 ms·
Any dynamic memory allocation lacks determinism, which is why in high integrity systems it often forbidden to dynamically allocate memory. As for Rust can be f
by jonathanstrange 8y ago
Any dynamic memory allocation lacks determinism, which is why in high integrity systems it often forbidden to dynamically allocate memory.
As for Rust can be faster than C, well, people said the same about Ada but it rarely is the case so I wouldn't hold my breath for Rust either. After all, those languages use the same backends - GCC in the case of C & Ada, LLVM in the case of C & Rust. But it's enough to as fast as optimized C and have all the safety features.
- jcranmer 8y ago> After all, those languages use the same backends - GCC in the case of C & Ada, LLVM in the case of C & Rust. The killer flaw of C for performance is the pointer aliasing problem. C only has the very coarse-grained tools of strict aliasing (often disabled in large applications because it breaks code!) and restrict (which relies heavily on manual programmer annotation) to control these aliasing issues. Since Rust has the rule that you can only have one mutable reference to an object at once (and read-read aliasing issues don't matter), it can effectively automatically add in these annotations without relying on programmer annotation.
- arcticbull 8y agoI think it's fair to say that "average" Rust code will be faster than "average" C code due to lack of pointer aliasing issues as the average developer doesn't care about/understand this enough to make the annotations in any codebase I've worked in. Can you make both equally fast? I don't see why not, they're both LLVM.
- setr 8y agoGiven enough time, effort and smarts, you can probably make any lang as fast as any other :-)
- arcticbull 8y agoRust doesn't require a heap, you can use it fully statically and still get the deterministic destructors when your stack object is destroyed.
- jonathanstrange 8y agoThe same for Ada, and it also has strict aliasing rules, but that hasn't made it faster than C historically. It's in the same ballpark as C, though.