Quote Originally Posted by nuzzle View Post
The articles state that programmers should avoid the explicit use of new/delete. Instead alternatives such as library containers and smart pointers should be preferred. The reason is that the new/delete combination is prone to programmer mistakes and errors. So the less you use them the less you're going to f**k them up so to speak.

But this doesn't mean dynamic memory allocations generally should be avoided in C++. Technically it's no more error prone than any other kind of memory allocation. Any memory allocation can fail. And you're not going to have any memory leaks unless you put them there yourself.

There are situations when dynamic memory allocations shouldn't be used but the reason isn't that programmers may shoot themselves in the foot. The reason is that there are no timing guarantees. You don't know how long a heap allocation/deallocation may take so it cannot be used when you write programs with hard timing constraints.

The object oriented programming style relies heavily on dynamic object allocations. To claim that you should avoid using new is a big joke really. It's the same as saying that C++ cannot handle OO and you better use Java or C# instead.

So by all means, minimize the use of new/delete as much as possible because you're only human and bound to make an error sooner or later. Instead use alternatives such as library containers and smart pointers (or even a garbage collector). But it's a mistake to avoid dynamic memory allocations especially in OO. Dynamic memory allocation is an important part of the C++ language and shouldn't be avoided.
I think you took the points posted by Lindley and Paul to a wrong context/interpretation and posted the above. I don't see where they said to avoid dynamic memory. Of course, its essential. But the point I understand that was being made, was about handling the memory yourself using plain malloc/free, new/delete or whatever allocation/deallocation routines which can be beneficial to beginners (this is an opinion). I don't think they questioned the dynamic memory as such just the way they are handled in a program. These are so called guidelines, if you feel comfortable with fire, of course you are free to tame it.
Quote Originally Posted by nuzzle View Post
So by all means, minimize the use of new/delete as much as possible because you're only human and bound to make an error sooner or later. Instead use alternatives such as library containers and smart pointers (or even a garbage collector). But it's a mistake to avoid dynamic memory allocations especially in OO. Dynamic memory allocation is an important part of the C++ language and shouldn't be avoided.
I don't see a disagreement here, so all's well.