4 ms·
My guess would be that in order to be safe you'd also have to seriously constrain other aspects of the language (like casts for instance). You'd probably have t
by simias 10y ago
My guess would be that in order to be safe you'd also have to seriously constrain other aspects of the language (like casts for instance). You'd probably have to introduce something like rust's "unsafe" to turn those checks off locally. You'd have to add additional syntax to manage lifetimes. Basically you'd reimplement Rust in C++.
99% of the C++ code out there wouldn't compile anymore and a lot of it would require significant re-architecturing in order to work with the new paradigm.
Or more likely the vast majority of the codebase would keep working in "legacy" mode which wouldn't play nice with the safe portions of the code (since you'd have to consider all calls to the rest of the code as unsafe). Same thing with any external library not updated to be "safe". It's like the python 2 -> 3 transition, except a lot worse because it's significantly more complicated and probably can't be automated easily.
The reason C++ was so successful is because of its backward compatibility (all the way back to C). I'm not sure it'd make a lot of sense to introduce such radical changes now. Especially given how incredibly huge the language is already.