3 ms·
I'm not arguing any of these points. I'm just saying there are these two misconceptions: - if you write safe rust code, your code can't segfault This isn
by shadowmint 12y ago
I'm not arguing any of these points.
I'm just saying there are these two misconceptions:
- if you write safe rust code, your code can't segfault
This isn't true if your code path contains any unsafe code.
- Rust code can't segfault
This isn't true at all.
Sure, if it does segfault its a bug in the c code / unsafe code.
You're absolutely correct.
...but bugs aren't deliberate. Obviously no one is going to deliberately expose a c api that has segfaults in it.
The misconception is that if you're using rust you're safe from the bugs that other programmers may have made... which is not true.
There's a trust chain involved; if you depend on a library you trust it's bug free and won't delete your harddisk and crash your program, but there's a difference between trusting a library is not malicious, and trusting a library is bug free.
If you have to trust the library is bug free, you're really no better off than using C++ are you?
...but people keep saying that if you use rust then there are certain types of safety that are guaranteed by the language: http://doc.rust-lang.org/reference.html#behavior-considered-unsafe http://doc.rust-lang.org/reference.html#behavior-considered-..., regardless of programmer bugs.
It's just not true.
Once again, I'm not arguing that safety is good or bad or whatever. My assertion is very very specific:
Rust code written 100% safely can crash if it has a dependency that uses unsafe code.
The assertion that 100% safely written rust code with arbitrary dependencies can't crash is false.
- dbaupp 12y ago> The misconception is that if you're using rust you're safe from the bugs that other programmers may have made... which is not true. Of course it's not true, but the libraries you're using will (hopefully, for the most part) be written in Rust, which increases the level of trust. > There's a trust chain involved; if you depend on a library you trust it's bug free and won't delete your harddisk and crash your program, but there's a difference between trusting a library is not malicious, and trusting a library is bug free. > If you have to trust the library is bug free, you're really no better off than using C++ are you? The libraries are written in Rust, so have all the benefits of that. It is nonsense to say that "libraries can have bugs so you might as well use C++".
- shadowmint 12y ago> It is nonsense to say that "libraries can have bugs so you might as well use C++". My argument is that if you assert 'rust is 100% safe' then you must assert, all your dependencies are bug free. If you can somehow magically assert 'all my code is bug free', that would be great... but if so, you wouldn't need the borrow checker at all would you? (I'm certainly not endorsing using C++ :P I'm specifically talking to the assertion that rust code can be safe, as per the definition of safety in the guide, that certain operations are impossible; certainly, and absolutely, rust code is safer and more trust worthy (imo) than c/c++ code... but you've got to be reasonable about what you're arguing. 'rust is magical and can never crash' turns up in blog posts a lot)
- kibwen 12y ago> 'rust is magical and can never crash' turns up in blog > posts a lot The next time that you see someone doing this, please correct them. Misinformation does none of us any favors.
- kbenson 12y agoI believe that's what started this entire thread. ...there are two things in this article which are, I'd say, 'common misconceptions' about rust.
- kibwen 12y ago> If you have to trust the library is bug free, you're > really no better off than using C++ are you? This is a pretty far-out argument. For any programming language and environment, unless every dependency of your program including the compiler and runtime can be proven correct via formal verification, you will be susceptible to bugs. That doesn't imply that all code in the world is topologically as unsafe as C++. I can segfault Python if I try hard enough, and that's a bug in Python. Likewise I can segfault safe Rust code if I try hard enough, and that's a bug in Rust. I don't believe that anyone is really of the misconception that the mere use of Rust absolves you from the bugs of others, because that same person would have to believe that Rust somehow makes all bugs impossible, including bugs in C code that Rust calls into. So let me give everyone a source to cite on Wikipedia: "Rust does not keep C code from segfaulting." ~ kibwen
- akavel 12y agoI don't understand -1s to the parent post; it's important to remember and be aware of limitations and dangerous areas in a language (or any other tool). And shadowmint tries to describe them in very civilized and calmly assertive way. I find his posts, as well as the counterarguments (like those from pcwalton and wycats), massively educative and informative. I absolutely can't understand why someone would like to see them fade out and disappear. I see the thread as exactly a kind of educated, professional argument that is so valuable on HN. And in such, being partially wrong or incorrect in some aspect is not something "bad" and "requiring censorship", but rather opportunity for straightening by others with a side effect of educating the larger community, isn't it?
- anonbanker 12y agoUpvoted grandparent based on this post.