5 ms·
The mention of memory safety is kind of weird. Reading or writing to -1 in C is memory safe too. It's even sometimes done deliberately as a debug technique if y
by tedunangst 10y ago
The mention of memory safety is kind of weird. Reading or writing to -1 in C is memory safe too. It's even sometimes done deliberately as a debug technique if you want to insert messages in your IO traces. (Wrt your post that rust is more than just safety, people will get that impression when you introduce memory safety into unrelated threads.)
- deleted 10y ago[deleted]
- steveklabnik 10y agoWhile Rust is more than memory safety, it's really important that people accurately understand what safety actually means in Rust. Because then they oversell it. Common misunderstandings here: * Rust prevents deadlocks * You can't leak memory in Rust * Rust prevents race conditions * Panic is not safe etc. In my mind, bringing up memory safety here isn't a red herring; the parent said this: > However Rust is billing itself as a safe systems programming alternative to C and C++. The way in which we are safer is memory safety, nothing more. And knowing that is crucial. Rust code will have bugs. Rust code will have security vulnerabilities. Rust is not a panacea.
- jdf 10y ago> The way in which we are safer is memory safety, nothing more. I know you want to not overstate rust's claims given recent articles, but I think you're actually underselling a little here. For example, a rust `enum` make it much easier for the compiler to enforce code correctness. It's hard to go back to similar code in C or Go once you've gotten used to `match`.
- steveklabnik 10y agoYes, I guess in my mind, "correctness" and "memory safety" are two different things. I like that Rust can help you write more correct software, but it's not nearly as strong of a guarantee as our memory safety guarantees are.
- p0nce 10y agoThe Rust frontpage is kind of promoting these misunderstandings: https://www.rust-lang.org/en-US/index.html https://www.rust-lang.org/en-US/index.html > prevents segfaults Only outside unsafe blocks. > guarantees thread safety. But you just said you can have deadlocks and race condition, so... perhaps change the frontpage?
- tatterdemalion 10y agoThe guarantees Rust makes are always only outside of unsafe blocks. After all, you can call C code in unsafe blocks. :) The page clarifies later on that the definition of thread safety in question is "threads without data races." The 16 words on the front page of the website are not the appropriate place to go into caveats and nuances.
- p0nce 10y agoThe urge to write something clear and short should not lead to write a false fact. Or at least have asterisks.
- steveklabnik 10y agoWe've tried to come up with something succinct to replace "thread safety", but it's tough. > Only outside unsafe blocks. This is just true of all of our guarantees. Given that the vast, vast, vast, vast majority of Rust code is safe code, I don't feel this is misleading. Do you say that Ruby doesn't prevent segfaults due to its C FFI?
- p0nce 10y agoI don't see an inaccurate statement on the Ruby frontpage: https://www.ruby-lang.org/fr/ https://www.ruby-lang.org/fr/ edit: I'm just saying "don't lie". I shouldn't have to defend this view point and get downvotes for it.
- Manishearth 10y agoIt's not a lie. Terminology has nuance, and its meaning may change based on context.
- kibwen 10y ago> The mention of memory safety is kind of weird. While teaching Rust it's a recurring theme among students to believe that all crashes are created equal and that an exit from a panic must be equivalent to a segfault, despite this being significantly false. So it's common when discussing panics to novice audiences to sprinkle in "by the way, this isn't a crash, it's a controlled exit".
- pcwalton 10y ago> Reading or writing to -1 in C is memory safe too. Is it? It's out of bounds of any object, and therefore undefined behavior.
- tedunangst 10y agoFile descriptor -1, as in the same thing we're unwrapping in the rust code. In C, if socket() returns -1, that's actually a monad that you can pass to bind() and listen() and accept() and then check for errors. :)