Hacker News new | ask | show | jobs
by dannymi 1043 days ago
>Does Rust give you _maximum_ control over performance the way C and C++ do?

In general yes.

What do you mean, exactly?

Rust doesn't have hidden things going on in your programs--and the culture is very much "if it's slow it should be visible in the source code".

1 comments

It's hard to say what I mean exactly, because I don't know what I will need to make my program fast, but I know I want the ability to adapt and control low level details. That would include memory layout and allocation, and skipping potential safety checks if I can prove my code works, beyond what the type system and compiler can prove.

I had some Swift code a while back. It was optimized, but when I rewrote it in C++ it got a lot faster. Something bad was happening that wasn't "visible in the code", as you said. The code was pretty complex algorithm and data structure stuff related to computational geometry and computer graphics. I suspect if I tried it in Rust I'd be fighting with the borrow checker and that is not appealing.