← Back to context

Comment by ranger_danger

1 month ago

even safer languages like rust still do not prevent against many problems, such as: logic errors, stack overflows, out of memory errors, bitflips, memory leaks, unrecoverable errors (panic's), memory safety related issues in an unsafe context

That's not quite true. Stronger type systems such as in Rust, OCaml and Haskell do help prevent logic errors. Also Rust can provide very precise control over memory allocation so that can help with OOMs.

No language that I'm aware of protects against bit flips or claims to have memory safety in its memory unsafe escape hatches (kind of the point).

It's like saying seat belts, air bags, and crumple zones do not prevent all automobile deaths. They don't, but they help a whole lot. Prevention of all bugs converges with artificial superintelligence and/or solving the halting problem (which is impossible).

There are formal languages that do more than Rust, but they're a lot less practical. Working on making a more practical one would be a useful exercise.

You can forbid unsafe at the Cargo.toml level in Rust. You can also just search a project for the keyword "unsafe" to subject all unsafe code to extra levels of scrutiny. Some orgs set commit rules where commits containing "unsafe" must be approved by more people or must pass through a security audit team.