<div dir="ltr">On 29 May 2013 17:18, Rainer Schuetze <span dir="ltr"><<a href="mailto:r.sagitario@gmx.de" target="_blank">r.sagitario@gmx.de</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
<br>
On 29.05.2013 02:46, Steven Schveighoffer wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, 28 May 2013 20:40:03 -0400, Manu <<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>> wrote:<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
ObjC and WinRT are both used successfully on embedded hardware, I'm<br>
really<br>
wondering if this is the way to go for embedded in D.<br>
V8 uses an incremental collector (somehow?), which I've been saying is<br>
basically mandatory for embedded/realtime use. Apparently Google agree.<br>
Clearly others have already had this quarrel, their resolutions are worth<br>
consideration.<br>
</blockquote>
<br>
An interesting thing to note, Apple tried garbage collection with Obj-C,<br>
but only on MacOS, and it's now been deprecated since automatic<br>
reference counting was introduced [1].  It never was on iOS.<br>
<br>
So that is a telling omission I think.<br>
<br>
-Steve<br>
<br>
[1] <a href="https://en.wikipedia.org/wiki/Objective-C#Garbage_collection" target="_blank">https://en.wikipedia.org/wiki/<u></u>Objective-C#Garbage_collection</a><br>
</blockquote>
<br></div></div>
Please note that you have to deal with circular references manually in Objective-C, introducing two types of pointers, strong and weak. I don't think this is optimal. If you want to deal with circular references automatically you again need some other kind of other garbage collection running.<br>

<br>
A problem with the naive approach of atomic reference counting a counter inside the object (as usually done in COM interfaces, I don't know how it is done in Objective-C) is that it is not thread-safe to modify a pointer without locking (or a CAS2 operation that you don't have on popular processors). You can avoid that using deferred reference counting (logging pointer changes to some thread local buffer), but that introduces back a garbage collection step with possibly massive destruction. This step might be done concurrently, but that adds another layer of complexity to finding circles.<br>

<br>
Another issue might be that incrementing a reference of an object when taking an interior pointer (like you do when using slices) can be pretty expensive because you usually have to find the base of the object to access the counter.<br>

<br>
I won't dismiss RC garbage collection as impossible, but doing it efficiently and concurrently is not so easy.<br>
</blockquote></div><br></div><div class="gmail_extra" style>What do you think is easier, or perhaps even POSSIBLE in D?</div><div class="gmail_extra" style>A good RC approach, or a V8 quality concurrent+incremental GC?</div>
<div class="gmail_extra" style>I get the feeling either would be acceptable, but I still kinda like idea of the determinism an RC collector offers.</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>
I reckon this should probably be the next big ticket for D. The long-standing shared library problems seem to be being addressed.</div></div>