Reputation
1,475
Next privilege 2,000 Rep.
Edit questions and answers
Badges
13 15
Newest
 Announcer
Impact
~82k people reached

  • 0 posts edited
  • 1 helpful flag
  • 142 votes cast
2d
comment Why Garbage Collection if smart pointers are there
@user1703394: "Unbounded pauses due to destructors is an unfortunate property of RAII being used for non-memory resources". No, this has nothing whatsoever to do with non-memory resources.
Feb
10
comment Why Garbage Collection if smart pointers are there
@user1703394: "You have no idea". These ad-hominem attacks are pointless. If there is a reason why you think anything you have referred to is even relevant to this discussion please state it specifically. I agree that Rust is cleaner and safer than C++ and provides a new perspective but that has nothing whatsoever to do with this discussion. Unbounded pauses due to destructors avalanching will be just as prevalent in Rust as they are in C++. Move semantics address a completely unrelated problem. Here is the infinite loop in Rust: doc.rust-lang.org/stable/nomicon/destructors.html
Feb
9
comment Why Garbage Collection if smart pointers are there
@user1703394: "the least pervasively used type of smart pointer". You are implying that weak_ptr is more common than shared_ptr.
Feb
9
comment Why Garbage Collection if smart pointers are there
@user1703394: "broader concept of smart pointers". Smart pointers are not a broader concept.
Feb
9
comment How does garbage collection compare to reference counting?
@gnasher729: "Studies prove what they want to prove". The vast majority of GC research over the past 56 years has concluded that tracing is faster than reference counting though a few die hards continue to pursue RC, e.g. in "Down for the count? Getting reference counting back in the ring" users.cecs.anu.edu.au/~steveb/downloads/pdf/rc-ismm-2012.pdf
Feb
9
comment How does garbage collection compare to reference counting?
@Snowman: "modern languages...Java...C++" . There's something so very wrong with that. :-)
Feb
9
comment How does garbage collection compare to reference counting?
@ALXGTV: "requires a large memory space". This has now been tested and disproven by the "iOS Memory Performance" section of the following benchmark where Swift uses 4x more memory than either Java (RoboVM) or C# (Xamarin). medium.com/@harrycheung/…
Feb
9
comment Why Garbage Collection if smart pointers are there
@user1703394: "this answer should be moved to a question on reference counting. I'ts a poor reference counting answer to a good smart pointer question". You seem to be having a purely emotional response to these facts.
Feb
9
comment Why Garbage Collection if smart pointers are there
@user1703394: "ignore actual usage patterns of the different types of smart pointers". I have observed these phenomena many times on real C++ code bases over the past 20 years. You don't even need to use shared_ptr to see unbounded pauses due to destructors avalanching.
Jan
29
comment Demonstration of garbage collection being faster than manual memory management
Yes, absolutely. No additional effort to write but writing code isn't the bottleneck with C++. Maintaining code is. Maintaining code with this kind of incidental complexity is a nightmare. Most industrial code bases are millions of lines of code. You just don't want to have to deal with that. I've seen people convert everything to shared_ptr just to fix concurrency bugs. The code is a lot slower but, hey, now it works.
Jan
28
comment Demonstration of garbage collection being faster than manual memory management
@Mehrdad:"Have you eliminated such potential sources of error?". Yes. OCaml has a very simple compilation model with no optimisations such as escape analysis. OCaml's representation of the closure is actually substantially slower than the C++ solution so it should really use a custom List.filter as the C++ does. But, yes, you are certainly quite right that some RC operations can be elided. However, the biggest problem I see in the wild is that people don't have the time to perform such optimisations by hand on large industrial code bases.
Jan
28
awarded  Announcer
Jan
27
comment Demonstration of garbage collection being faster than manual memory management
Sure. Install OCaml with the native code ocamlopt compiler under Linux or Mac OS X. Compile the program with ocamlopt nqueens.ml -o nqueens and run it with ./nqueens 11 to get the result for n=11.
Jan
27
comment Why are reference-counting smart pointers so popular?
@Deduplicator: "with and without GC". You meant with tracing GC and with reference counting, right?
Jan
27
comment Why are reference-counting smart pointers so popular?
@Deduplicator: I can envisage programs that give either outcome. Reference counting would outperform tracing GC when the program is designed to keep heap allocate memory until it survives the nursery (e.g. a queue of lists) because that is pathological performance for a generational GC and would generate the most floating garbage. Tracing garbage collection would require less memory than scope-based reference counting when there are many small objects and lifetimes are short but not statically well known so something like a logic program using purely functional data structures.
Jan
27
comment Why are reference-counting smart pointers so popular?
@Deduplicator: "And the optimisation in F# which according to the comments only sometimes works is ending the lifetime earlier, if the variable is not used again. Which naturally has its own perils". That is called liveness analysis and it is done by all production compilers not just F#. It is nothing "special" as he claims. C++ compilers were doing this long before F# existed. They do not spill everything to the stack for the entire scope as he claims. He obviously has no idea how compilers work...
Jan
27
comment Why are reference-counting smart pointers so popular?
@Deduplicator: "He doesn't understand that the lifetime is the full scope which goes up to the closing brace". I understand that perfectly well. Indeed, that is the whole point of my blog post: C++ shared_ptr keeps floating garbage around to the end of scope contrary to common folklore that it collects at the earliest opportunity.
Jan
27
comment Why are reference-counting smart pointers so popular?
@Deduplicator: "Don't create any garbage unless you have gobs of idle resources or cannot help it". I have never seen any concrete evidence that scope-based reference counting requires less memory than tracing garbage collection.
Jan
27
comment Is garbage collection needed for implementing safe closures?
@user102008: Yes, see: cs.virginia.edu/~cs415/reading/bacon-garbage.pdf
Jan
27
comment Why are reference-counting smart pointers so popular?
@Deduplicator: I'm afraid there is no such misunderstanding and no such "optimisation". If you can be specific then I can explain why but I suspect you now know you're wrong.