News for hackers. Stuff that matters.
Re:Why I Chose to Learn C by pjmlp on Friday March 29, 2013 @05:44PM (#5463193)
The biggest problem with manual memory management is when doing software in large teams.

Suddenly you have distributed knowledge across team members with various skill levels and producing memory leaks is very easy.

Nowadays automatic memory management in the form of GC or reference counting is the way to go.

Re:Why I Chose to Learn C by dkhenry on Friday March 29, 2013 @08:13PM (#5463755)
Or you can do what c++ and rust did which is neither reference counting or GC ( yes I know rust has a GC just stay with me for a little). Its a strong and distinct message about what you plan on doing with the memory your getting. When I run across a int* i don't know what your doing with it just by seeing its type, but if I run across a shared_ptr<int> I know its reference counted and will stick around until I am done with it and if I am the last one it will be free'd. In the same manner If i see a unique_ptr<int> I know that if i need it I must take it from someplace and the compiler will be kind enough to tell me if I messed it up somehow.
Re:Why I Chose to Learn C by pjmlp on Saturday March 30, 2013 @02:51AM (#5464696)
I fail to see how that is not reference counting, even if implemented at library level.
Re:Why I Chose to Learn C by mpyne on Saturday March 30, 2013 @04:40PM (#5466601)
shared_ptr probably does use reference counting, but unique_ptr doesn't.

There's literally only ever one "owner" of a unique_ptr, which is why the parent comment talked about taking it from somewhere.

C++ exchanges ownership of unique_ptr's in the move constructor or assignment operator (i.e. there's no "copy" operation available, unlike with std::auto_ptr). If a unique_ptr still happens to own a pointer when the unique_ptr is destructed, it knows to destroy the pointed-to object as well and free the memory, but the object itself is not reference-counted per se, there's only the Boolean sense "alive/dead".

Re:Why I Chose to Learn C by pjmlp on Sunday March 31, 2013 @03:10PM (#5469781)
That is still reference counting in any CS book about automatic memory management algorithms.
Re:Why I Chose to Learn C by mpyne on Monday April 01, 2013 @09:04AM (#5472755)
Only in the sense that

    MOV EAX, EBP
    XOR EBP, EBP
is "reference counting".
Re:Why I Chose to Learn C by pjmlp on Monday April 01, 2013 @10:11AM (#5473093)
x86 implementation detail....