News for hackers. Stuff that matters.
Re:Show HN: Smart pointers for the C programming language by jheriko on Wednesday January 14, 2015 @11:53AM (#8887410)
smart pointers are always dumb imo. GC or do it yourself - everything in between is always more of a headache in my experience. I've spent more time debugging reference counts in few code bases than debugging new/delete in many.
Re:Show HN: Smart pointers for the C programming language by dicroce on Wednesday January 14, 2015 @01:15PM (#8887975)
smart pointers are better than GC or do it yourself imo.

smart pointers and RAII allow me to explicitly model ownership and lifetime in a non imperative way. In addition, I am not subject to arbitrary GC runs with non deterministic amounts of work to do. Instead, objects simply go away as they are no longer needed in a completely deterministic way.

Re:Show HN: Smart pointers for the C programming language by evincarofautumn on Wednesday January 14, 2015 @01:25PM (#8888024)
Naïve reference counting is deterministic, but it may also do an arbitrary amount of work on a deallocation because it reclaims objects eagerly. Deferred/incremental reference counting is much more suitable for, say, games, which is what it sounds like you’re thinking of.
Re:Show HN: Smart pointers for the C programming language by pjmlp on Thursday January 15, 2015 @04:40AM (#8891654)
I guess you never experienced a stop-the-world caused by cascading destructors.
Re:Show HN: Smart pointers for the C programming language by koenigdavidmj on Wednesday January 14, 2015 @01:23PM (#8888013)
This also provides unique_ptr, which doesn't use reference counting, and enforces rules very similar to those of Rust's borrow checker. They allow you to avoid memory leaks by ensuring that you either free any memory you allocate or pass it to another function (who must either free it or pass it to somebody else, ad infinitum).
Re:Show HN: Smart pointers for the C programming language by Snaipe on Wednesday January 14, 2015 @11:57AM (#8887441)
Haha, I guess, but I think it's not about using them all over your code base -- there are always pros and cons in using RAII, smart pointers, GCs, and manual memory management, it's the programmer's job to balance it correctly.