D 2015/2016 Vision?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 12 01:59:53 PDT 2015


On Monday, 12 October 2015 at 08:49:24 UTC, Jonathan M Davis 
wrote:
> On Monday, 12 October 2015 at 08:21:24 UTC, Kagamin wrote:
>> On Thursday, 8 October 2015 at 14:13:30 UTC, Jonathan M Davis 
>> wrote:
>>> I've programmed extensively in C++ with smart pointers, and 
>>> in my experience, circular references are rarely a problem. 
>>> There are some cases where it's obvious that you have one 
>>> (e.g. where one object owns another and they need to talk to 
>>> each other), in which case you either use a normal pointer or 
>>> a weak reference, depending on which makes more sense. And in 
>>> the cases that you don't catch, you find them in testing, 
>>> figure out what should be a weak reference to get rid of the 
>>> circular dependency, you fix it, and you move on. It really 
>>> isn't a big deal in general, though I suppose that there 
>>> could be certain ways of designing programs where it would be 
>>> more problematic.
>>
>> That's all understandable. What's not understandable is when 
>> one insists that a necessity to figure out ownership for every 
>> non-resource object in C++ is superior to D.
>
> If you don't want to care about ownership, then use a GC. The 
> only other memory management model that I can think of where 
> you don't have to care about ownership is when everything is a 
> value type on the stack, so there's nothing to own.
>
> There are pros and cons to using a GC, and there are pros and 
> cons to use reference counting everything on the heap. I don't 
> think that either is objectively superior. It all depends on 
> what you're trying to do and what your requirements are.
>
> - Jonathan M Davis

Well technically, there is still ownership: the GC owns 
everything. But yeah, you don't need to care about for this very 
reason.



More information about the Digitalmars-d mailing list