2 ms·
The complexity of Rust is on another level, it's a huge language.
by fulafel 2y ago
The complexity of Rust is on another level, it's a huge language.
- baq 2y agoIt’s a tradeoff. The ownership rules are mostly the same as C. The difference is that Rust enforces them at compile time.
- fulafel 2y agoHrm. These are the top level Rust ownership rules according to the book[1]: Each value in Rust has an owner. There can only be one owner at a time. When the owner goes out of scope, the value will be dropped. C has none of these. Or borrowing, etc. [1] https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html https://doc.rust-lang.org/book/ch04-01-what-is-ownership.htm...
- baq 2y agoTo get robust software out of C you don't have many options other than to adopt these rules. You can have useful software which breaks all of these, but you don't want to maintain it.
- throwawaymaths 2y agoRobustness is relative. You can certainly write a cli that does everything in an arena; your GC is the OS and so going out of scope -- who cares. doing nothing and eliminating whole classes of errors from consideration (UAF e.g.) is incredibly maintainable. Or, as the old tale goes, your GC might be the software literally exploding (it's in an air to air missile)
- zifpanachr23 2y agoIt's widespread practice to notate who owns what in the comments in C code. "Ownership" as a concept comes from well established C best practices and a good C developer is going to understand exactly what you mean if you say something like "Caller owns the memory returned from this function" etc.
- wyager 2y agoUsing pointers correctly and safely in C basically requires tracking pointer rules substantially similar to the rust pointer rules, but in your head. Most people who don't do this just write incorrect code, although it might only rarely cause a serious problem.