I will throw a little hope out too. In 4 years, he is gone. |
Some people worry that won't be the case.
Wow. Things went off the deep end, eh? |
such is life
So what exactly are you complaining about? truck driver driving on highway" sort of thing to say. |
This is not a bad comparison. People buy off-roading vehicles, even though they'll spend 99% of their time driving on a regular road. That 1% matters, it's why they bought it!
It is right to assume that. |
Who else should assume this? Assume every programmer is a dumbass and reject all their code without 3rd party verification.
How does bounds checking inconvenience you? |
If it rejects code that does not have bounds checking then that is an inconvenience - it forces code rewrite if you did something a certain way.
This is why I would not be against the alternative I presented which gives guaranteed bounds but at no expense to the programmer.
Suppose you were dropped into a project and you had to use this hypothetical language. Would you be actively going out into the weeds just to turn off safety features? |
No, that would be bad practice after-all. However, I find it very annoying when I have a program planned out in my head but a different language forces me to do it some other way in order to play by its rules.
I can write the code from other languages in C++, I can't write all C++ in those other languages, that's the inconvenience.
So I assume you don't use RAII, then. After all, manually managing your resources just has the capacity to be incorrect. |
Obviously we use RAII due to the convenience way just as much if not more so for the safety. Safety that's also convenient - that's just perfection.
It literally takes more effort to type a cast that to not type it. |
You have to type to do a cast anyway, C++ is an explicit language. Each type of cast just has a different syntax, not sure what the argument here is.
I actually think it's a perfect example of how not to do it, because in every case where a cast is needed (other than dynamic_cast) it's more convenient to use a C cast than to use any other cast |
Very valid actually. I don't find the little extra typing to be that crazy, but I do end up using c-style casting more than the safer casting. I wouldn't particularly mind having c-style casts become "safer", but it would probably break backwards compatibility in the language.
Now, yes, writing out "static_cast" or "dynamic_cast" or whatever takes a tiny bit more effort than (double*). However, this is not the kind of thing that would force you into changing the logic of your program, it is simply a small syntax difference. This is an acceptably small sacrifice for extra safety.
While dereferencing the int pointer does indeed have undefined behavior, any usable compiler would have to define it in its implementation |
This is besides the point. If you have a char array that you want to cast to an int array, you can do so, just cast.
Again, C++ is an explicit AND statically typed language. You're simply not allowed to set one type of variable with a variable of another type. To do so requires a cast. Unless you want C++ to implicitly cast for you, then it makes complete sense not to allow something like int* = &charArray.
Even the other casts would not allow you to set a variable type with that of another type, you have to cast it to the correct type first.
You cannot argue for safety by saying that any feature or trait of C++ that has safety as a byproduct I must be against somehow. Again, I'm 100% for safety, just don't make me change how I code. Don't make me bend around safety, have the safety bend around me. That sounds odd.
Don't make me write recursive solutions that can overflow dangerously, have defined behavior. Don't let my integers overflow randomly, have defined behavior.
Check for bounds errors at compile time? Sure, but don't reject my code at compile-time just because you couldn't be 100% sure if my bounds were safe or not. Generate a bounds check in the background? Fine, no problem, it'll only trigger if I screw up.
Do you see the difference? I want safety to only kick in when I screw up, not just when I engage in programming where I
might screw up.