News for hackers. Stuff that matters.
Re:Why Rust helps even if you have to use a lot of `unsafe` by adgjlsfhk1 on Wednesday August 02, 2023 @01:07PM (#36973677)
> Because the prescription would be to become a very good programmer and learn how to write memory safe code

The problem isn't becoming a very good programmer. That's not difficult. The problem is becoming a very good programmer who is never tired or rushed. Any correct code in C will have implicit rules about how the memory is managed that are either written in comments or reside in the programmer's head. This doesn't work because eventually some will make a code change without understanding fully the implicit rule (often this person is the same person who figured out the rule).

Re:Why Rust helps even if you have to use a lot of `unsafe` by ActorNightly on Thursday August 03, 2023 @11:56AM (#36987620)
>The problem is becoming a very good programmer who is never tired or rushed.

So what stops that programmer from being lazy and wrapping all the blocks in unsafe in a Rust code base?

Re:Why Rust helps even if you have to use a lot of `unsafe` by adgjlsfhk1 on Friday August 04, 2023 @01:05AM (#36995691)
nothing, but a programmer who does so knows they are creating an abomination while in C, it's just a normal day. (and for anyone looking at the code, the rust version will look like a buggy mess, while the C version will look like correct C code).
Re:Why Rust helps even if you have to use a lot of `unsafe` by ActorNightly on Friday August 04, 2023 @02:54PM (#37004225)
Yeah this doesn't play out in real world.

Look at any large enterprise Java project. People take shortcuts and break things all the time, even with fairly strict typing and memory safety.

Of course you can enforce things like "no unsafes ever in codebase" on a project, but if you have to reply on guidance for development, then you can simply say "first we write a complete set of tests that are a contract on correct operation, then we develop code", at which point the language choice becomes irrelevant.

Re:Why Rust helps even if you have to use a lot of `unsafe` by DrMeepster on Saturday August 05, 2023 @09:09PM (#37017941)
Banning unsafe is actually really easy. Just one line `#![forbid(unsafe_code)]` at the start of your code.
Re:Why Rust helps even if you have to use a lot of `unsafe` by iknowstuff on Saturday August 05, 2023 @03:54PM (#37015737)
bottom line is: this doesn't happen. Feel free to study why not.