← Back to context

Comment by echelon

13 hours ago

Even forgetting the memory safety and async safety guarantees, the language design produces lower defect code by a wide margin. Google and other orgs have written papers about this.

There are no exceptions. There are no nulls. You're encouraged to return explicit errors. No weird error flags or booleans or unexpected ways of handling abnormal behaviors. It's all standardized. Then the language syntax makes it easy to handle and super ergonomic and pleasurable. It's nice to handle errors in Rust. Fully first class.

Result<T,E>, Option<T>, match, if let, if let Ok, if let Some, while let, `?`, map, map_err, ok_or, ok_or_else, etc. etc. It's all super ergonomic. The language makes this one of its chief concerns, and writing idiomatic Rust encourages you to handle errors smartly.

Because errors were so well thought out, you write fewer bugs.

Finally, the way the language makes you manage scope, it's almost impossible to write complicated nesting or difficult to follow logic. Hard to describe this one unless you have experience writing Rust, but it's a big contributor to high quality code.

Rust code is highly readable and easy to reason about (once you learn the syntax). There are no surprises with Rust. It's written simply and straightforwardly and does what it says on the tin.

Thats not special to rust in any way or form. Most of mentioned features are stolen from ML, and in some cases badly. Eg rust has unwrap thats basically a ticking time bomb waiting to blow up. Rust has many other ways to blow up the program. Its not only about memory safety (80% of rust apps in the wild dont benefit from "memory safety" in any way or form).

  • > Most of mentioned features are stolen from ML

    Rust is the most popular ML-derived language, so if some is considering Rust vs. some other language the chances are the other one they're considering does not have all the ML goodies.

  • IMHO every app benefits from memory safety.

    Memory safety doesn't only have security implications, but reduces crashes, misbehavior and corrupt data.

    You don't want either in any software, which has to fulfill a task in a productive way.

  • Okay, but the alternative isn't ML; virtually all of this software would otherwise be written in C or C++.

are you for real? Rust most definitely is not highly readable and the language reeks of complexity

  • Readable is relative; it’s much less readable than some languages, but much more than the ones it’s largely displacing.

    I would much rather try and figure out a bug in unfamiliar rust than in unfamiliar cpp.