<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1265">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 12.0px; font: 16.0px Times; color: #011892}
p.p4 {margin: 0.0px 0.0px 0.0px 12.0px; font: 16.0px Times; color: #011892; min-height: 19.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Helvetica}
span.s1 {direction: ltr; unicode-bidi: embed}
span.s2 {text-decoration: underline ; direction: ltr; unicode-bidi: embed}
span.s3 {text-decoration: underline}
</style>
</head>
<body>
<p class="p1">On 2014-02-01 07:35:44 +0000, Manu said:</p>
<p class="p2"><br></p>
<p class="p3">On 1 February 2014 16:26, Adam Wilson <span class="s1"><<a href="mailto:flyboynw@gmail.com"><span class="s2">flyboynw@gmail.com</span></a>></span> wrote:</p>
<p class="p3">On Fri, 31 Jan 2014 21:29:04 -0800, Manu <<a href="mailto:turkeyman@gmail.com"><span class="s3">turkeyman@gmail.com</span></a>> wrote:</p>
<p class="p4"><br></p>
<p class="p3">On 26 December 2012 00:48, Sven Over <<a href="mailto:dlang@svenover.de"><span class="s3">dlang@svenover.de</span></a>> wrote:</p>
<p class="p4"><br></p>
<p class="p3"> std.typecons.RefCounted!T</p>
<p class="p4"><br></p>
<p class="p3">core.memory.GC.disable();</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p3">Wow. That was easy.</p>
<p class="p4"><br></p>
<p class="p3">I see, D's claim of being a multi-paradigm language is not false.</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p3">It's not a realistic suggestion. Everything you want to link uses the GC,</p>
<p class="p3">and the language its self also uses the GC. Unless you write software in</p>
<p class="p3">complete isolation and forego many valuable features, it's not a solution.</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p3"> Phobos does rely on the GC to some extent. Most algorithms and ranges do</p>
<p class="p3">not though.</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p3">Running (library) code that was written with GC in mind and turning GC off</p>
<p class="p3">doesn't sound ideal.</p>
<p class="p4"><br></p>
<p class="p3">But maybe this allows me to familiarise myself more with D. Who knows,</p>
<p class="p3">maybe I can learn to stop worrying and love garbage collection.</p>
<p class="p4"><br></p>
<p class="p3">Thanks for your help!</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p3">I've been trying to learn to love the GC for as long as I've been around</p>
<p class="p3">here. I really wanted to break that mental barrier, but it hasn't happened.</p>
<p class="p3">In fact, I am more than ever convinced that the GC won't do. My current #1</p>
<p class="p3">wishlist item for D is the ability to use a reference counted collector in</p>
<p class="p3">place of the built-in GC.</p>
<p class="p3">You're not alone :)</p>
<p class="p4"><br></p>
<p class="p3">I write realtime and memory-constrained software (console games), and for</p>
<p class="p3">me, I think the biggest issue that can never be solved is the</p>
<p class="p3">non-deterministic nature of the collect cycles, and the unknowable memory</p>
<p class="p3">footprint of the application. You can't make any guarantees or predictions</p>
<p class="p3">about the GC, which is fundamentally incompatible with realtime software.</p>
<p class="p3">Language-level ARC would probably do quite nicely for the miscellaneous</p>
<p class="p3">allocations. Obviously, bulk allocations are still usually best handled in</p>
<p class="p3">a context sensitive manner; ie, regions/pools/freelists/whatever, but the</p>
<p class="p3">convenience of the GC paradigm does offer some interesting and massively</p>
<p class="p3">time-saving features to D.</p>
<p class="p3">Everyone will always refer you to RefCounted, which mangles your types and</p>
<p class="p3">pollutes your code, but aside from that, for ARC to be useful, it needs to</p>
<p class="p3">be supported at the language-level, such that the language/optimiser is</p>
<p class="p3">able to optimise out redundant incref/decref calls, and also that it is</p>
<p class="p3">compatible with immutable (you can't manage a refcount if the object is</p>
<p class="p3">immutable).</p>
<p class="p4"><br></p>
<p class="p3">The problem isn't GC's per se. But D's horribly naive implementation, games are written on GC languages now all the time (Unity/.NET). And let's be honest, games are kind of a speciality, games do things most programs will never do.</p>
<p class="p4"><br></p>
<p class="p3">You might want to read the GC Handbook. GC's aren't bad, but most, like the D GC, are just to simplistic for common usage today.</p>
<p class="p4"><br></p>
<p class="p3">Maybe a sufficiently advanced GC could address the performance non-determinism to an acceptable level, but you're still left with the memory non-determinism, and the conundrum that when your heap approaches full (which is _always_ on a games console), the GC has to work harder and harder, and more often to try and keep the tiny little bit of overhead available.</p>
<p class="p3">A GC heap by nature expects you to have lots of memory, and also lots of FREE memory.</p>
<p class="p4"><br></p>
<p class="p3">No serious console game I'm aware of has ever been written in a language with a GC. Casual games, or games that don't attempt to raise the bar may get away with it, but that's not the industry I work in.</p>
<p class="p5"><br></p>
<p class="p6">You can always force the GC to run between cycles in your game, and turn off automatic sweeps.<span class="Apple-converted-space">  </span>This is how most games operate nowadays. <span class="Apple-converted-space">  </span>It's also probably possible to create a drop-in replacement for the GC to do something else. <span class="Apple-converted-space">  </span>I could see if being *VERY* useful to make the GC take a compile-time parameter to select which GC engine is used. <span class="Apple-converted-space"> </span></p>
<p class="p5"><br></p>
</body>
</html>