<div class="gmail_quote">On Fri, Jan 8, 2010 at 1:58 AM, Walter Bright <span dir="ltr">&lt;<a href="mailto:walter@digitalmars.com">walter@digitalmars.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
Michel Fortin wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Le 2010-01-07 à 20:28, Walter Bright a écrit :<br>
<br>
  <br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Having a per-thread gc is an optimization, not a fundamental feature of the concurrency model. For one thing, it precludes casting data to immutable. For another, it may result in excessive memory consumption as one thread may have a lot of unused data in its pool that is not available for allocation by another thread.<br>

    <br>
</blockquote>
<br>
Both the &quot;per-thread GC + shared GC&quot; model and &quot;the shared GC for everyone&quot; model can be seen as optimizations. The first optimizes for speed, the second optimize for memory usage.<br>
<br>
Depending on what you do, it might even make sense to have some threads using the shared GC for everything and other having a thread-local GC to improve speed.<br>
<br>
If you want the language to be limited to models where the memory can always be shared between all threads, then that that&#39;s fine. It&#39;s your prerogative. I&#39;m not so sure it&#39;s wise to limit shared semantics to this scenario just to avoid having the shared-immutable combo, but if you&#39;re sure that&#39;s what you want then I&#39;ll stick to it.<br>

<br>
  <br>
</blockquote>
<br>
There&#39;s another aspect here. Consider all the problems we have getting across the idea of an immutable type. What hope is there for shared? I see mass confusion everywhere. Frankly, I see little hope of any but a handful of programmers ever being able to grok shared and use it correctly for concurrent programs. The notion that one can just slap &#39;shared&#39; on a data type and have it work correctly across threads without further thought is a pipe dream.<br>

<br>
So what to do?<br>
<br>
I want to pin the mainstream concurrency on message passing. The message passing user never sees shared, never has to deal with locks, never has to deal with memory barriers. It just works. Message passing should be a robust, scalable solution for most users. I believe the Erlang experience validates this. Go and Scala also rely entirely on message passing (but they don&#39;t have immutable data, so their models are unsafe and I predict many rude surprises).<br>

<br>
So why bother with shared at all?<br>
<br>
Because message passing does not cover all the bases, and D is supposed to be a systems programming language. So we need a paradigm for synchronization and shared data structures. What shared provides is:<br>
<br>
1. A way to identify shared data. This is incredibly important. A lot of sharing bugs come about because of inadvertant unrecognized sharing of data. This should be pretty much impossible in D. Furthermore, if you do have a sharing bug in your code, you look at the 1% of the data tagged as shared, rather than every freakin&#39; line of code and every piece of data. Half the battle in debugging code is figuring out where to look for the problem. Shared pares that problem down to a reasonable size.<br>

<br>
2. Shared comes with a collection of static typing rules and guarantees that will head off a number of concurrency bugs, such as sequential consistency.<br></blockquote><div><br>For those of us who showed up late to class, is there a page or description that enumerates the typing rules and guarantees, or are those all still up in the air?<br>
<br>Kevin<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I view shared as sort of like the latest electric arc welders which automatically adjust the current and wire feed for you. They dramatically shorten (but don&#39;t eliminate) the learning curve for people trying to master the art of welding. D is the only language to even attempt this. C++ leaves you completely on your own, Java offers no help, Erlang, Scala and Go throw in the towel and won&#39;t allow anything but message passing.<br>

<br>
As for a shared gc vs thread local gc, I just see an awful lot of strange irreproducible bugs when someone passes data from one to the other. I doubt it&#39;s worth it, unless it can be done with compiler guarantees, which seem doubtful.<br>

_______________________________________________<br>
dmd-concurrency mailing list<br>
<a href="mailto:dmd-concurrency@puremagic.com" target="_blank">dmd-concurrency@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-concurrency" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-concurrency</a><br>
</blockquote></div><br>