Because we can both agree up to a certain point. However, even if we both agreed it would be "better" for there to be doctors in cars, we would also agree this should never be mandated. Hence, you can't argue that we should keep making something safer and safer and screw everything else because even YOU would not want that. We are simply disagreeing at where the line should be drawn.
There's no reason to let you mix that kind of control with normal code arbitrarily |
But as a C++ programmer, you already know this going in. You know you're working with a low-level language. You know they give little guardrails. You know it is up to you to deal with memory and everything. All the dangerous features give us intuition we're first starting out and fail with them. I simply don't like the idea of making it so safe, it would require such an overhaul of the language.
And all for what? We already have Rust. I don't hate Rust and I don't think people should not use it. I'm basically saying C++ has a lot of room to give defined behavior to things which are current UB and room for creating alternative safe coding routes. But to argue for overhauling the language for safety? That's just creating another Rust language, and you can't argue (successfully) otherwise.
After re-reading this like six times, what I'm getting from this is that you want C++ to contain as little UB as possible by changing its semantics but not its grammar |
It's important for C++ to maintain backwards compatibility, period. This is better for the language and keeps programmers from having to learn anything new. C++ has never been about that.
If I wanna get lost in overhauls and code-changes, I'd program everything in C#. I appreciate C# getting better, but it's annoying. C++ has never been for such overhauls.
changing the semantics will still break people's programs, and more subtly, and there's no way people will agree on which way to break it. |
It depends, I don't necessarily think people's programs would break. For example, if your integer overflows, you should probably assume it simply wrapped around - many compilers do that already.
Stack overflow? ANY solution will be fine, as there's no way for the programmer to have any safety against it already.
Going beyond an array's bounds? Crash I guess? Any program doing so is already broken, you can't break it further.
Does your program get away with de-referencing a pointer you already freed? Crash. Again, the program is already broken and cannot be broken further with this fix.
Uninitialized variables? Give them a default value... maybe. I actually kind of like having a random number in there. However, that's still UB still we don't know what to expect from an uninitialized variable, some compilers do give them a default value.
There's just SO MANY of these that can be fixed up and make the language a lot better without anyone possibly being upset.
But apparently the biggest issue is that my pointer arithmetic isn't in an unsafe context? It feels like we're talking about sex and it's getting shamed for doing it in public.