In my experience over 90% of C/C++ developers are basically unaware of alternatives to fine grained allocation with malloc()/free() or new/delete. Many have heard of pool allocators, but they almost invariably see it as something even more complicated or tricky, applicable only in high performance code (meaning, not theirs). Very few have heard of arena allocation as a way to massively simplify lifetime management.
Now OK, temporal memory safety isn't the only problem. But it is the costliest and most difficult to solve at the language level. So imagine a langage that only helps with spatial memory safety (systematic bounds checks in debug or release-safe modes), and their programmers stick to the simpler allocation schemes like arenas.
It won't get rid of all the memory vulnerabilities. But it may very well get rid of enough of them that they cease to be a priority. It might even be a better tradeoff overall than a borrow checker or even a better security tradeoff, depending how much friction the borrow checker adds.
On the other hand, we should not underestimate the productivity boosts of strict static analysis, most notably type systems: I have experienced first hand the advantages of being told with ruthless precision why my pathetic attempt at a program didn't deserve to be even started. It's a tighter feedback loop than even a REPL (though I like it best when I have both), and speeds us up in many cases, including exploratory programming.
I'm not sure why this wouldn't generalize to other behaviors including coding, and that's the argument against the "language1" is safer than "language2" discussion. Left with only that distinction, the coder is less likely to take extra precautions just as Americans who are safer wearing their seatbelt choosing to travel above the speed meant to be safe for the road and it's inhabitants, ignoring the fact that their seatbelt does not protect pedestrains or fauna.
That the lanuage does technically offer a statistical safety advantage provides no assurance against foot-gunning, despite offten being portrayed as such.
I don't know if there's really a good analogy for driving cars because it would have to be a completely eliminated class of error, like "drivers drive slower and are less likely to hit potholes when they perceive danger, i.e. on a road with many potholes, however if we eliminated all potholes in existence, drivers hit even fewer potholes".
Anyway, humans stopped coding sometime this year, so it's all kinda a moot point.
Same with coding: no one cares if you abstain from ASan and UBSan if the end result has no memory safety bug. Unfortunately, times and times and times and times again have shown that thinking "I just need to write perfect C code" does not help reduce memory safety bugs, while using Rust does.
Why? Because making a Rust program with more intricate memory access rules compile is way way more annoying than in C. This is intended.
> That the lanuage does technically offer a statistical safety advantage provides no assurance against foot-gunning
The zero-cost memory safety provided by Rust is enforced by the compiler restricting all kinds of foot-gunning, sometimes even stupidly (unlike in GC languages where the GC just cleans up all the bullet wounds). Saying Rust let users foot-gun themselves easily is one thing, but saying it's easier to foot-gun in Rust than in C is unfathomable.
This analogy does not hold up. Nobody sane would seriously advocate that everybody drive around with a chef's knife just because it makes the driver more careful.
Humans make mistakes. We are exposed to the mistakes of other humans. There are factors that are out of our control.
The only serious approach to safety given this reality is defense in depth. Removing layers of defense because "it will make the humans behave more carefully" in other layers is fallacious reasoning.
That is the sort of thing some people advocate in the vehicle case though. They suggest reducing visibility etc. on purpose even though it actually makes it harder to avoid a collision because some drivers overcompensate and then the e.g. -15% you get from people being more cautious is more than the +12% you get from drivers not being able to see pedestrians as easily.
But there are a few problems with the theory. The first is that they hardly ever do long-term studies, and then people may not stay more cautious once they get used to the change even though you've permanently reduced visibility. The second is that if you make a road feel more dangerous then some people would avoid the road, and then you measure fewer collisions on it because it has less traffic, but you're only moving the collisions somewhere else while still actually reducing visibility on that road.
And the third is that it's a false dichotomy. There are ways to make a road less dangerous other than making it feel more dangerous, and we should prefer those over the ones that impose countervailing costs.
As a programmer I am not the driver. If I was, I might truly be more careful. But the drivers are people far away that I don't know and don't really care about.
Other avenues for bad are still there though.
It's more typing, but it's also less thinking because you get the code to compile immediately. And if you don't like typing then that's easy, just write "unsafe" once inside a function that you can call in 500 different places.
At some point you have to actually care or it's not going to work out.
It's usually the opposite. If you're being forced to write unsafe, odds are there's a crash bug about to appear (the word "forced" was very specifically chosen, I've been in both of these positions quite a few times).
And if you're not being forced to write unsafe, not writing it really is easier. Precedence of operations means that if you want to call a method/access a field of a raw pointer, it's a minimum of `(*a).` to reference it. A reference is just the `.`.
I've made a plugin to valgrind that stabs the engineer with a knife when they do unsafe things. Does the engineer accomplish their next task with rust or C?
Whether this is true or not, it's positioned as a bad thing because time and effort spent on memory safety isn't purely an additive benefit. It can actively reduce memory safety (high-perf Rust software needing more unsafe than we care to admit, and unsafe Rust being harder to write correctly than normal C), and it can fight against time spent focusing on other serious vulns (e.g., the cap-primitives issue is important because we're failing to do things as simple as when we run literally arbitrary code bothering to make sure it's the right code).
And that's only from a security perspective where legitimately informed and intelligently people disagree about whether Rust actually reduces vulns in high-performance code (again, whichever side you fall on, that's the argument being made). There's additional pushback against Rust when people would otherwise be silent about its security shortcomings because it has enough other tradeoffs in its design to hinder other metrics developers care about, like speed of feature delivery (or, in the age of vibecoding, cost of tokens and therefore also speed of correct feature delivery).
There are a bunch of in-process security measures you can take if you do not have an RCE, none of them matter with an RCE.
If we're going to beat up on Java for having some bad hand optimized internals... guess what, Rust has it in spades, with more than a dozen memory corruption CVEs over the years.
Yes, memory-safe languages are better for application development. But Rust is not unique here; most GC'd languages satisfy the requirement.
I thought about what hardening techniques there are for dealing with RCE in a process but short of SELinux policies I can't really think of anything that might help.
The problem is ultimately that any RCE can overcome any in-process security mechanism you come up with. If you have an RCE, the security logic has to be enforced by a process that is not a victim of an RCE.
The best way to deal with a threat model with inevitable RCE is to ultimately give up and come up with a general RCE mitigation.
For example, a hypothetical ISA could mark valid entry points for functions and if you skip them, the process aborts. This prevents using just the last instruction of a gadget but ultimately I think even that type of mitigation is useless against an LLM. You are simply better off doing your bounds checks.
I'm talking about RCEs, because most in-process security measures work best if they cannot be bypassed and an RCE is always an implied bypass.
OpenBSD implemented this for syscalls: https://man.openbsd.org/pinsyscalls.2
Rust's standard I/O abstractions are intended to be cross-platform, which means they're unfortunately going to be approximately the lowest common denominator of what the platforms natively provide. If you're okay with not strictly adhering to cross-platform abstractions, then the cap-std crate is the state of the art: https://crates.io/crates/cap-std
Forcing hardware makers to be responsible for the first 3 layers of the OSI model would be a great start.
You realise they are memory managed languages right?
Also it contains a ton of unsafe.
Any other wisdom you wish to share?
Making it extremely easy to collaborate with large numbers of packages and maintainers, while also making it difficult to audit (packaged source code not linked to a particular git commit).
There are plenty of valid complaints that don't touch application logic or memory safety. Coming from someone who likes aspects of rust despite these problems, there is certainly room for improvement at the package ecosystem levels.
It's challenging to accept such a statement when the past 30 days have featured no less than six extremely high-profile memory safety bugs in critical infrastructure (PHP, Brotli, nginx, Java, Ruby...). No compiler can prevent bugs in application logic, but automatically catching the most common and exploitable class of bugs should be a compelling feature and it's surprising to see it positioned as somehow a bad thing.