I find it puzzling that someone mentions Java here as easier to optimize due to lack of pointers; as opposed to
C++, it's a language with reference semantics (and if you think there are no pointers look
here), so there's even more of an indirection (and all the related implications apply, including but not limited to
aliasing). If anything, Fortran is indeed a good example.
Naturally, pointer aliasing is more of a problem for another language, called "C".
C++ is a different language, with different typing discipline, which enables
type-based alias analysis, with obvious implications for compiler optimization.
Lastly, folks who mention GC in the context of memory leaks/releasing memory seem to be somewhat misinformed as to what are GC advantages and what it's
for:
But it also has advantages of being more convenient for the user that they don’t have to worry about object ownership (not “releasing the memory” – if you hear that GC solves the problem of “releasing the memory” it means you talk to an idiot) and it’s also faster than manual (heap-based) memory allocation, as well as can lead to less memory fragmentation and stronger object localization.
I haven't seen "delete" (or "delete[]" for that matter) used "by hand" in a modern
C++ code-base for well over a decade and "forgetting to delete" was never really a problem outside of last-century marketing materials for the managed languages. And if one really wants to go that route, then
C++ with unified treatment of resources (be it memory, files, locks, network connections, etc.) via RAII is by far easier and automatic compared to having to remember to use try-catch-finally or try-with-resources constructs "by hand" (I mean, if the
C++ alternative for one resource is a problem for a programmer when coding in C-style (and it really isn't when writing
C++ in
C++), then having to manually remember about various try constructs for all kinds of resources must be an insurmountable challenge for that same programmer ;]).