3 ms·
Writing the application logic in Rust isn't different from doing it in any other Algol-like procedural language. You even get nice functional abstractions. The
by orthoxerox 6y ago
Writing the application logic in Rust isn't different from doing it in any other Algol-like procedural language. You even get nice functional abstractions.
The learning cliff is in the memory management. Rust combines no GC with no memory leaks by forcing you to prove to it that your algorithm doesn't leak anything. And you have to do this every time you want your code to compile.
There's no way in Rust to write your business logic first and plug the memory leaks later. And it's not just the compiler issue, the whole ecosystem expects you to think about the right abstraction for managing memory from step zero.
This means that when you're writing Rust as a novice or a journeyman you have to simultaneously think about the correctness of your algorithm and about its memory safety.
- swsieber 6y agoSafe rust actually let's you leak memory if you want. It tends not happen unless you try (in my limited experience). What it does prevent is memory unsafely: read after free, double free, buffer overflows, etc.
- hu3 6y agoRust doesn't prevent memory leaks. I thought I'd chime in since I see this claim often around these parts. See: https://doc.rust-lang.org/book/ch15-06-reference-cycles.html https://doc.rust-lang.org/book/ch15-06-reference-cycles.html > Rust combines no GC with no memory leaks by forcing you to prove to it that your algorithm doesn't leak anything. And you have to do this every time you want your code to compile.
- pkolaczk 6y agoWhile Rust may not guarantee freedom from memory leaks (probably no Turing complete language can), I find it makes a much better job on resource management than many other GCed languages. I find it is much easier to leak a file descriptor in Java than in Rust.
- orthoxerox 6y agoIt doesn't prevent all memory leaks, but its goal is the prevention of most memory leaks/buffer overruns and other memory management errors with zero runtime overhead.