top | item 13222064

(no title)

wangchow | 9 years ago

What about smart pointers? It gives the flexibility and benefits of garbage-collection without the performance degradation. It's not a silver bullet but it helps.

What I'm getting at is, Rust is the only modern language (in vogue at the moment) that does not use garbage collection. It would be nice if more languages didn't require a garbage collector but gave the option to use one.

If there are some more of such languages please chime in and provide a link to them! :)

discuss

order

tomp|9 years ago

> flexibility and benefits of garbage-collection

Not really, as it doesn't allow/collect cycles.

> without the performance degradation

Only for single-threaded code.

I agree with the rest of your comment!

prodigal_erik|9 years ago

A smart pointer is just a way to add custom behavior when it's created and destroyed. The question is what the smart pointer does. Usually the answer is update a reference count, which happens so frequently that it ends up being a lot more expensive (especially in bus bandwidth) than occasionally tracing live objects between long periods of useful work.

mike_hearn|9 years ago

D has optional GC. However in hindsight it is perhaps not so smart. The problem is that it fractures the ecosystem: some libraries require GC and others don't. If you don't want to use it you have to rely only on non-GC libraries.

user5994461|9 years ago

Smart pointers are as hard to manage as pointers.

There are different kind of smart pointers and you gotta think what you want to do with them. A GC is easier.

wangchow|9 years ago

GC is certainly easier. However, it is important to understand the life-cycle of objects regardless. To be able to control them (if desired) is good because in many cases one would prefer to have that control instead of being forced to use garbage collector.

In an ideal world, garbage collector makes sense because we don't want to have to worry about life-cycle management when we are solving other problems. Memory management can indeed be an annoying implementation detail, but as it stands there are certainly limiting factors in hardware which are impacted by generic object-management for specific application domains.