• HMH
    link
    103 years ago

    Rust eliminates a lot of memory safety problems at compile time. Roughly speaking once you allocate memory and assign a variable to it, that variable “owns” said memory. A variable owning memory is responsible for its lifetime and just like in many other programming languages once it goes out of scope, the memory is released.

    So far so boring. What makes Rust different is the borrow checker. It ensures that all references (equivalent to pointers in C) to some memory (in this case not owned), are always valid. Like that it is impossible to access invalid blocks of memory in (safe) Rust. You never have to wonder who is responsible for deallocating memory and you never have to fear dangling pointers as those simply do not exist in Rust.

    I am sure there is much more to it, but this is certainly one of the arguments.