News for hackers. Stuff that matters.
Re:Tour of Rust by orthoxerox on Sunday July 12, 2020 @10:24AM (#23811507)
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.

Re:Tour of Rust by hu3 on Sunday July 12, 2020 @11:10AM (#23811942)
Rust 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

> 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.

Re:Tour of Rust by pkolaczk on Sunday July 12, 2020 @12:40PM (#23812605)
While 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.
Re:Tour of Rust by orthoxerox on Sunday July 12, 2020 @12:57PM (#23812756)
It 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.
Re:Tour of Rust by swsieber on Sunday July 12, 2020 @11:01AM (#23811865)
Safe 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.