<story><title>For Better Computing, Liberate CPUs from Garbage Collection</title><url>https://spectrum.ieee.org/tech-talk/computing/hardware/this-little-device-relieves-a-cpu-from-its-garbage-collection-duties</url></story><parent_chain><item><author>geocar</author><text>&amp;gt; But all of these are much cheaper than developer labour and reputation damage caused by leaky&amp;#x2F;crashy software.&lt;p&gt;And that&amp;#x27;s why so much effort has gone into making it fast and low latency, but it was a false dichotomy: We can have memory safety without garbage collection.&lt;p&gt;- Automatic reference counting: Most people know about Objective-C&amp;#x27;s efforts in this space, but it&amp;#x27;s admittedly less automatic than programmers would like so perhaps it doesn&amp;#x27;t get enough attention. And yet it should, since q&amp;#x2F;kdb+ uses reference counting exclusively, and it holds top performance numbers on a large number of data and messaging problems.&lt;p&gt;- Linear lisp[1] asked functions to fully consume their arguments making (cons x y) basically a no-op. Again, no garbage collection, and no fragmentation (at least as long as all objects are cons), and yet no matter how promising this path looked, garbage collection got much more attention.&lt;p&gt;- Rust&amp;#x27;s borrow checker&amp;#x2F;tracker makes ownership explicit; somewhat of a middle-ground between the two...&lt;p&gt;There&amp;#x27;s other scattered efforts in this space, and I don&amp;#x27;t know about all of them but for more on &amp;quot;everything we know about languages is wrong&amp;quot;, also consider that Perl5 uses plain old reference counting, executes the AST directly, and still outperforms python for data and IO[2]!&lt;p&gt;I think the thing to take away is that memory management has to be automatically managed for developer sanity, &lt;i&gt;not&lt;/i&gt; that garbage collection is the way to do it.&lt;p&gt;[1]: &lt;a href=&quot;http:&amp;#x2F;&amp;#x2F;home.pipeline.com&amp;#x2F;~hbaker1&amp;#x2F;LinearLisp.html&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;home.pipeline.com&amp;#x2F;~hbaker1&amp;#x2F;LinearLisp.html&lt;/a&gt;&lt;p&gt;[2]: The asyncio stuff in Python looks really promising though...</text></item><item><author>davedx</author><text>&amp;gt; It wastes time, it wastes space, it wastes energy.&lt;p&gt;But all of these are much cheaper than developer labour and reputation damage caused by leaky&amp;#x2F;crashy software. The economics make sense.&lt;p&gt;Anecdotally, I spent the first ~6 years of my career working with C++, and when I started using languages that did have GC, it made my job simpler and easier. I&amp;#x27;m more productive and less stressed due to garbage collection. It&amp;#x27;s one less (significant) cognitive category for my brain to process.&lt;p&gt;Long live garbage collection!</text></item><item><author>arcticbull</author><text>IMO garbage collection is the epitome of sunk cost fallacy. Thirty years of good research thrown at a bad idea. The reality is we as developers choose not to give languages enough context to accurately infer the lifetime of objects. Instead of doing so we develop borderline self-aware programs to guess when we&amp;#x27;re done with objects. It wastes time, it wastes space, it wastes energy. If we&amp;#x27;d spent that time developing smarter languages and compilers (Rust is a start, but not an end) we&amp;#x27;d be better off as developers and as people. Garbage collection is just plain bad. I for one am glad we&amp;#x27;re finally ready to consider moving on.&lt;p&gt;Think about it, instead of finding a way of expressing when we&amp;#x27;re done with instances, we have a giant for loop that iterates over &lt;i&gt;all of memory&lt;/i&gt; over and over and over to guess when we&amp;#x27;re done with things. What a mess! If your co-worker proposed this as a solution you&amp;#x27;d probably slap them. This article proposes hardware accelerating that for loop. It&amp;#x27;s like a horse-drawn carriage accelerated by rockets. It&amp;#x27;s the &lt;i&gt;fastest&lt;/i&gt; horse.</text></item></parent_chain><comment><author>tomp</author><text>This comment is just bad and misinformed all over.&lt;p&gt;(1) &lt;i&gt;Automatic Reference Counting&lt;/i&gt; doesn&amp;#x27;t work; its equivalent in interpreted languages is, well, &lt;i&gt;reference counting&lt;/i&gt;, which can be optimized quite a lot (though has some issues with multithreading), but cannot collect cycles.&lt;p&gt;(2) therefore, if you want reference counting, you have to either also have GC (for cycles), or program carefully to avoid creating cycles (which is then only marginally better than C++)&lt;p&gt;(3) your comment on Python vs Perl5 is just nonsense, Python uses reference counting as well (along with the occasional GC to collect cycles)&lt;p&gt;(4) linear &amp;#x2F; uniqueness types (not exactly the same, but both can be used to ensure safe memory management) impose significant mental overhead on programmers as they prohibit many common patterns&lt;p&gt;(5) Rust features a lot of &amp;quot;cheating&amp;quot; - pointers that allow mutation from multiple threads, reference-counted pointers, etc. - so obviously just ownership&amp;amp;borrowing isn&amp;#x27;t good enough&lt;p&gt;&lt;i&gt;conclusion:&lt;/i&gt; you can&amp;#x27;t have your cake and eat it too (at least according to current cutting edge research and implementations) - you either have GC &lt;i&gt;or&lt;/i&gt; you have to be very careful&amp;#x2F;restricted when writing code</text></comment>
<story><title>For Better Computing, Liberate CPUs from Garbage Collection</title><url>https://spectrum.ieee.org/tech-talk/computing/hardware/this-little-device-relieves-a-cpu-from-its-garbage-collection-duties</url></story><parent_chain><item><author>geocar</author><text>&amp;gt; But all of these are much cheaper than developer labour and reputation damage caused by leaky&amp;#x2F;crashy software.&lt;p&gt;And that&amp;#x27;s why so much effort has gone into making it fast and low latency, but it was a false dichotomy: We can have memory safety without garbage collection.&lt;p&gt;- Automatic reference counting: Most people know about Objective-C&amp;#x27;s efforts in this space, but it&amp;#x27;s admittedly less automatic than programmers would like so perhaps it doesn&amp;#x27;t get enough attention. And yet it should, since q&amp;#x2F;kdb+ uses reference counting exclusively, and it holds top performance numbers on a large number of data and messaging problems.&lt;p&gt;- Linear lisp[1] asked functions to fully consume their arguments making (cons x y) basically a no-op. Again, no garbage collection, and no fragmentation (at least as long as all objects are cons), and yet no matter how promising this path looked, garbage collection got much more attention.&lt;p&gt;- Rust&amp;#x27;s borrow checker&amp;#x2F;tracker makes ownership explicit; somewhat of a middle-ground between the two...&lt;p&gt;There&amp;#x27;s other scattered efforts in this space, and I don&amp;#x27;t know about all of them but for more on &amp;quot;everything we know about languages is wrong&amp;quot;, also consider that Perl5 uses plain old reference counting, executes the AST directly, and still outperforms python for data and IO[2]!&lt;p&gt;I think the thing to take away is that memory management has to be automatically managed for developer sanity, &lt;i&gt;not&lt;/i&gt; that garbage collection is the way to do it.&lt;p&gt;[1]: &lt;a href=&quot;http:&amp;#x2F;&amp;#x2F;home.pipeline.com&amp;#x2F;~hbaker1&amp;#x2F;LinearLisp.html&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;home.pipeline.com&amp;#x2F;~hbaker1&amp;#x2F;LinearLisp.html&lt;/a&gt;&lt;p&gt;[2]: The asyncio stuff in Python looks really promising though...</text></item><item><author>davedx</author><text>&amp;gt; It wastes time, it wastes space, it wastes energy.&lt;p&gt;But all of these are much cheaper than developer labour and reputation damage caused by leaky&amp;#x2F;crashy software. The economics make sense.&lt;p&gt;Anecdotally, I spent the first ~6 years of my career working with C++, and when I started using languages that did have GC, it made my job simpler and easier. I&amp;#x27;m more productive and less stressed due to garbage collection. It&amp;#x27;s one less (significant) cognitive category for my brain to process.&lt;p&gt;Long live garbage collection!</text></item><item><author>arcticbull</author><text>IMO garbage collection is the epitome of sunk cost fallacy. Thirty years of good research thrown at a bad idea. The reality is we as developers choose not to give languages enough context to accurately infer the lifetime of objects. Instead of doing so we develop borderline self-aware programs to guess when we&amp;#x27;re done with objects. It wastes time, it wastes space, it wastes energy. If we&amp;#x27;d spent that time developing smarter languages and compilers (Rust is a start, but not an end) we&amp;#x27;d be better off as developers and as people. Garbage collection is just plain bad. I for one am glad we&amp;#x27;re finally ready to consider moving on.&lt;p&gt;Think about it, instead of finding a way of expressing when we&amp;#x27;re done with instances, we have a giant for loop that iterates over &lt;i&gt;all of memory&lt;/i&gt; over and over and over to guess when we&amp;#x27;re done with things. What a mess! If your co-worker proposed this as a solution you&amp;#x27;d probably slap them. This article proposes hardware accelerating that for loop. It&amp;#x27;s like a horse-drawn carriage accelerated by rockets. It&amp;#x27;s the &lt;i&gt;fastest&lt;/i&gt; horse.</text></item></parent_chain><comment><author>eru</author><text>Compare the &amp;quot;Unified Theory of Garbage Collection&amp;quot; (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.cs.virginia.edu&amp;#x2F;~cs415&amp;#x2F;reading&amp;#x2F;bacon-garbage.pdf&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.cs.virginia.edu&amp;#x2F;~cs415&amp;#x2F;reading&amp;#x2F;bacon-garbage.pdf&lt;/a&gt;).  Reference counting is a variant of garbage collection.  But yes, you can take ideas from their to make your garbage collection better.&lt;p&gt;Linear&amp;#x2F;uniqueness typing is interesting.  Clean is another language that uses something like it, and you can implement these ideas in Haskell as well.&lt;p&gt;Though in practice you want affine typing, not linear typing.  (Basically, you want to be able to drop arguments without explicitly having to consume them.)  The important bit about linear typing &amp;#x2F; affine typing is that you use your arguments at most once, not that you have to use them at least once.&lt;p&gt;That&amp;#x27;s how you can model mutation in a pure FP way, too.  Not just GC.</text></comment>