|
|
|
|
|
by robalni
1613 days ago
|
|
I don't know what people mean when they talk about "safe" or "unsafe" code.
Doing something like `int a[5]; a[2] = 100;` in C is perfectly safe because there is no bug in that code.
The only thing that might be unsafe about that is if you change the code because then you might create a bug.
Changing code is always unsafe because you can always create bugs in any language, even Rust. I don't think "safe" or "unsafe" can be a property of code; it can only be a property of something you do, like changing code.
I think that something being "unsafe" means that there is a risk with doing it.
Programming is always a risk, even if you write Rust code without using the "unsafe" keyword.
You can even have arbitrary code execution bugs in Rust programs without using the "unsafe" keyword; think about bugs like SQL-injections. All of this doesn't mean than I don't think the checks that the Rust compiler does help.
They probably help many people to write less buggy code.
I just think it makes no sense to call code "safe" or "unsafe". |
|