r/cpp • u/tjroberti • Oct 22 '26
Revisit Safe C++
Everyone is aware of the deluge of vulnerabilities now hitting critical software. It even makes the mainstream news, so software safety is coming onto politician's radars.
If this gets worse, I think it is not inconceivable that at some point memory safe software becomes mandatory. Or at least for software that is "reachable" from the internet.
So is it time to revisit Sean Baxter's Safe C++? Start out with a safe context ("safeexpr") and expand from there, just like constexpr.
37
Upvotes
View all comments
Show parent comment
-2
u/arthurno1 Oct 24 '26
Common Lisp has been in the use for 30+ years, and completely hides the hardware below. I have recently being playing with trying to get Common Lisp to run as fast as C++, and it seems to be fully possible. But: I need an escape clutch from the managed runtime, which SBCL has (I can emit assembly and get unchecked access to memory via raw pointer).
Now, I am not sure about this, but to achive the bare-metal speed, we do need unrestricted access (as much as possible) to the hardware below. Rust also has a clutch to escape into the "unsafe" code. I am affraid anyone who want to run 100% speed on bare-metal will want a cluth. However, I also believe 95% or 99% of bare-metal speed if more than enough for most of the applications.
I think any language with dynamicism, i.e. not completely static programs, will have to restrict access to raw hardware in order to ensure safety; at least somewhere. C++ is designed to allow creating of objects at runtime, so not everything can be fully statically determined, so some form or "management" will always be needed, and that is where some tradeoff will be made. In other words: yes- and no-sayers would have to agree somewhere and make a trade-off.