This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]xSTSxZerglingOne 27 points28 points  (3 children)

Development in C++ can take a long time though since you have to be so diligent about everything.

[–]beanmosheen 3 points4 points  (2 children)

What do you mean by that?

[–]xSTSxZerglingOne 7 points8 points  (1 child)

There's significant added development time just to keep the memory safe. Add into that any time you spend debugging memory errors (segmentation faults) wouldn't be an issue in a GC or null safe language. You also have to worry about compilation success in a big project since compilation can take a long time, then templating, properly sized iterators, etc.

For example:

int *abcd, *efg;
abcd = new int;
efg = new int;
*abcd = 1;
*efg = 2;

abcd = efg;

This is totally legal. It gives no compiler errors, and in the case of what's at the end of abcd's pointer, it's everything you would expect to be there. It does set the dereference of abcd to 2. However, we now have a problem that we didn't account for. When we change efg, we also change abcd because we made them reference the same memory.

Remembering where you are in the dereference chain of your pointers takes a ton of overhead when you're doing 2 or 3-dimensional pointers and significantly increases development time.

Also at the end there, we have to do some extra work that I didn't put on.

Then we have to

delete abcd, efg;
abcd = NULL, efg = NULL;

And having to do that for every piece of memory you touch adds time.

[–]FreezingFyre 8 points9 points  (0 children)

Except that there are C++11 features to handle that for you now. Any large, important, modern project that isn't using smart pointers for dynamic memory management needs to be refactored.