4 ms·
> Rust imposes one of the possible disciplines for memory-object management Could you give some examples of other possible disciplines?
by oconnor663 6y ago
> Rust imposes one of the possible disciplines for memory-object management
Could you give some examples of other possible disciplines?
- dathinab 6y agoThe thing is anything which can break your code implicitly in messed up ways like memory violations require unsafe code which if possible should be avoided and most important makes it easier to pinpoint what to review if you run into unexpected strange bugs. Sure reviewing unsafe code isn't perfectly ready often it relies on invariants uphold outside of the unsafe blocks (in the same type). Still much better then having to review everything ;=)
- ncmncm 6y agoThere are lots. For a single-threaded program, moving around unique_ptrs or, equivalently, value objects, suffices. For parallel execution, maybe you add threads and mutexes, or futures, and possibly shared_ptr or a moral equivalent. The point is that you have a lot of choices to make that are only peripherally related to the problem the code is supposed to be solving. Those choices might allow you to tune the performance of operations better to the problem, but they may be just a distraction from the goal. For most systems, nobody knows how fast it should be able to go, or whether you got close. Almost as often nobody even cares very much, or cares at all. When they don't, it is wasted effort to spend a lot of time and skull-sweat optimizing performance. There, a straitjacket language that offers few choices is best. It lets you get on to the next thing.