N
Noah Roberts
For example, I start to tend to favour Java over C++ because whenever I
make some grave mistake and get a Memory Access Violation, this is more
or less the end of the world for a C++ application. Java, in contrast,
nicely captures this and gives me an exception. This not only makes me
able to shut down gracefully, but also provides me with enough error
information about where I went wrong (there is no standard way under C++
to retrieve the stacktrace of an exception). I don't understand why such
a feature is not important enough to make it into the C++ standard,
while such gimmicks like lambdas and whatnot get huge attention.
To a great degree this kind of feature IS in the standard. The vector 'at'function for example throws an exception if bounds are violated. This is all Java does.
The main difference here is that C++ doesn't impose this upon you. The 'at' function is provided for times when you really need to do bounds checkingand other operations are provided for when you really do not.
I think the problem comes when people pay too much attention to the C part of C++. Raw arrays and such are mostly a thing of the past in C++. There's no really good reason to use them outside of a backward compatibility scenario. I believe the library provided abstractions are even quite competitive in the high-performance, micro-optimization niche.