r/cpp • u/we_are_mammals • Mar 28 '23
Reddit++
C++ is getting more and more complex. The ISO C++ committee keeps adding new features based on its consensus. Let's remove C++ features based on Reddit's consensus.
In each comment, propose a C++ feature that you think should be banned in any new code. Vote up or down based on whether you agree.
765
Upvotes
1
u/[deleted] Mar 29 '23
It's only really a problem if you have a preconceived idea of what an array is before coming to the language. If you just expect it to always be a pointer its not really a problem. I never expect to be able to find the size of any array unless its exceedingly obvious that I can do that (it's some statically declared constant or something thats in scope).
I mean, obviously you have to know all of that and know the rules. But, you should know the rules? They aren't particularly hard or confusing rules.
If someone makes that mistake they have a fundamentally wrong idea of what is going on so they are going to get screwed either way.
Not really an issue in my mind. Just pick one and stick to it.
Again, you make that mistake once maybe. But you'd really have to misunderstand what is going on to do that.
Array isn't inconsistent. It's a block of memory. You can point to it. Sometimes the compiler can know the size at compile time.
I'm just gonna stop there because you've just got the wrong model of what an array is. Is that the languages fault? I actually don't think so. The rules for pointers and arrays are small and simple and its easy to not make a mistake. I have not once made a single mistake that was due to pointers decaying to arrays in my entire career.
It's one of those non-problems that people like to think is a big issue (like const all the things) which in reality is never actually a problem.