News for hackers. Stuff that matters.
Re:For Better Computing, Liberate CPUs from Garbage Collection by jandrewrogers on Thursday May 09, 2019 @08:57AM (#19867835)
I tend to take the position that arguments about the merits of GCs are proxies for a different issue at a higher level of abstraction that is rarely tackled directly. One of the correctly argued advantages of GC is that it automatically handles some difficult edge cases like ambiguous lifetimes and cyclical references. In my opinion, there is an interesting discussion to be had around why these edge cases need to be solved in real software systems.

At least in my experience, the cases that GCs solve uniquely well are a code/architecture smell. Every time I've written some complex code that creates the edge cases GCs solve well, it has been a red flag for poor design. I've never run into one of these cases where there was not a different, better design that made these edge cases go away in a sensible manner. In a sense, GCs primarily help developers by allowing them to ignore issues of poor design (which may not be their fault) in order to get things done. While there are obvious merits to the "just get things done" view, the reality is that the sloppy design that leads to these kinds of situations tend to be strongly correlated with other software problems that a GC won't paper over.

Programming languages strive to enable and encourage good design with their feature set. There is an interesting philosophical debate about language features that exist almost solely to mitigate the effects of poor design, which IMHO is where GCs fit. Does availability lead to enablement in practice?

Re:For Better Computing, Liberate CPUs from Garbage Collection by bunderbunder on Thursday May 09, 2019 @09:44AM (#19868193)
This hits on something I've been wondering about lately:

For those of us who might want some of the performance characteristics of Rust, but not to the extent that we're willing to take on all of the strictures it imposes, what's the feasibility of building a compiler that can avoid GC for objects whose lifetime can be determined statically, while still retaining GC for the rest?

My (wild) guess is that it wouldn't actually gain you any real practical advantage over a good generational GC, but still, I'm curious if anyone has looked into something like that.

Re:For Better Computing, Liberate CPUs from Garbage Collection by babyloneleven on Thursday May 09, 2019 @01:05PM (#19870032)
Compilers of managed languages already do this optimization when they can prove that a variable has a static lifetime. Look up scape analysis.

The trouble is, this is hard to do for non-trivial code (and in the general case is uncomputable).

Re:For Better Computing, Liberate CPUs from Garbage Collection by babyloneleven on Thursday May 09, 2019 @01:06PM (#19870047)
I'm not finding how to edit, but, it's called escape analysis
Re:For Better Computing, Liberate CPUs from Garbage Collection by rienbdj on Thursday May 09, 2019 @11:51AM (#19869326)
I think this was the promise of D. For some reason it's not very popular.