Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Garbage Collection Central

Name: Anonymous 2013-11-17 21:43

Let us discuss garbage collection!

Name: Anonymous 2013-11-17 21:44

It's a shit!

Name: Anonymous 2013-11-17 21:52

My garbage gets collected on Tuesday. I wish it were on Monday instead, because I'm often too tired Monday night to remember to take it out.

Name: Anonymous 2013-11-17 22:01

>>2
Nonconstructive.

Name: Anonymous 2013-11-17 22:28

I'm normally in the `It's shit, end of discussion' camp, but recently I've been thinking that this is really caused by attempting to bolt it onto C-like languages. The problem is that GC has to, one way or another, at some point know exactly whether an allocated object is reachable from current context. What makes this hard is that you can take arbitrary references to an object in C/Java/Sepples/etc. If the following code were illegal:

o = create_some_big_object();
a = o;
do_something_with_object(o);
do_something_else_with_object(a);


Because a and o were both references to the same memory, GC would be a lot better. So if you had a language that operated kind of like this:

object *o, a, b; // All implicitly (or explicitly) NULL
create_some_big_object(&o); // The memory is created with exactly one reference
transfer_reference(&o, &a); // The memory still has exactly one reference - o is NULL'd
// do_something_with_object(o); // This would be illegal, o is NULL
do_something_with_object(a); // This is fine
copy_reference(&a, &o); // Now the memory has exactly two references
do_something_with_object(o); // This is now fine
transfer_reference(&b, &o); // Still two references
close_reference(&b); // Now one reference - a
transfer_reference(&b, &a); // Now one reference - b
close_reference(&b); // Now zero references, memory is reclaimed at exactly this point.


I think Rust is doing something along this path, with owned references and transferring references, but I haven't had time to look into Rust (partially because every time I look at it they've made major structural changes to the language, and I want to wait for it to settle down), and I'm sure there have been languages in the past that did this, but I haven't seen any. Obviously, the syntax is shit in my example, but I think the basic point: that you have to explicitly duplicate references, could make it work.

The bit where this would really work is in the case where you transfer a reference into a field of a structure, because close_reference could do a walk and sanely close out child references as well, and transfer_reference can sanely close references to its clobbered arg.

But obviously, this doesn't work too well when you have a language that allows programmers to skip close_reference, or to take pointers in any other method than from creation or copy_reference, etc. Sepples tried something like this with RAII, but I wouldn't exactly call Sepples a model of perfection for that. So in order to create this model as a usable language, I think C-ish syntax would have to be thrown away.

Name: Anonymous 2013-11-17 22:58

>>1,5
I'm in the ``It's great, except when it's implemented by idiots, which is most of the time'' camp.

I dislike forced manual deallocation because that it clutters up the code and it is overkill for small allocations/deallocations where escape analysis could automatically free memory instead. Conversely, I find it important to be able to manually deallocate things when the program flow is too complex for escape analysis to handle and not doing so would cause a large amount of memory/CPU-time to be wasted. However, I would ballpark that 99% of allocations don't need to have a deallocation point manually specified.

Name: Anonymous 2013-11-18 1:32

>>6

It seems like we don't have trouble coming up with the requirements for a language that would give all of that. But what implementations out there will do this? With letting you do manual allocations and deallocations when you want while the optimizing compiler determines allocation methods automatically for the other objects. Does D have an optimizing allocator like this?

Name: Anonymous 2013-11-18 1:57

>>7
I seem to recall reading that D used Boehm GC under the hood, but I may be wrong. If that's the case, Boehm is probably the thing to look at anyway.

Name: Anonymous 2013-11-18 16:30

>>8
You're thinking of Mono. Pretty sure D rolls its own allocator.

Name: Anonymous 2013-11-19 7:57

>>7
It seems like we don't have trouble coming up with the requirements for a language that would give all of that. But what implementations out there will do this?
Probably no proper existing implementations, because if it ain't Lisp it's crap, and Lisp is shit, so everything is either shit or crap (maybe except Symta which is neither Lisp nor not Lisp).

while the optimizing compiler determines allocation methods automatically for the other objects.
It's really more about ``when is the earliest I can provably safely deallocate something?''. The only difference I can think of in the allocation method is if you want to do stack allocations instead of heap.

Name: Anonymous 2013-11-19 23:25

>>10
There is stack allocation versus heap allocation. But then there is also heap allocation where container deletes children when container is freed, reference counting where container removes references counts on children when the container is freed, and then more general garbage collection where the container just removes its links to its child objects when freed and the lifetime of the children are processed by the gc. And maybe there are more. That's all I can write off the top of my head.

Name: Anonymous 2013-11-20 20:03

>>5
But obviously, this doesn't work too well when you have a language that allows programmers to skip close_reference, or to take pointers in any other method than from creation or copy_reference, etc. Sepples tried something like this with RAII, but I wouldn't exactly call Sepples a model of perfection for that. So in order to create this model as a usable language, I think C-ish syntax would have to be thrown away.

Not quite. Rust enforces this through the type system.

Name: Anonymous 2013-11-20 20:16

>>12
Not quite. Rust enforces this through the type system.
Hmm, I really should get around to learning Rust. I wonder if there's been a consensus on a decent ncurses binding yet.

Name: Anonymous 2013-11-21 0:32

>>13
Get motivated:
http://blog.theincredibleholk.org/blog/2013/11/18/booting-to-rust/
A couple nights ago I was looking over the UEFI spec, and I realized it shouldn’t be too hard to write UEFI applications in Rust. It turns out, you can, and here I will tell you how.
The thing that surprises me most about UEFI is that it now appears possible to boot your machine without ever writing a single line of assembly language.

Name: Anonymous 2013-11-21 1:06

>>14
UEFI
That's not motivating. That's just depressing and makes me want to give up computers altogether.

Name: Anonymous 2013-11-21 6:21

>>15
It should motivate you to research its weaknesses so we can bypass it at some point before it's completely adopted.

Name: Anonymous 2013-11-28 10:05

It's a stupid language feature. It produces stupid programmers.

A programmer who doesn't collect his garbage himself is a garbage programmer.

Name: Anonymous 2013-11-28 11:32

how human brain handles GCing?

Name: Anonymous 2013-11-28 12:02

>>17
It's a stupid language feature. It produces stupid programmers.

A programmer who doesn't assemble his code himself is a garbage programmer.

Name: Anonymous 2013-11-28 12:43

>>19
Good spirit, but I feel like you missed the point by not translating the final joke. What about this?

A programmer who doesn't assemble his code himself is only half a programmer

?

Name: Anonymous 2013-12-01 22:35

>>18
With Physics[1].

Neuron pathways that aren't used "shrink", forming less and less connections over time, being activated less, consuming less resources, and eventually they are entirely relocated.

The brain also performs synaptic pruning[2] from the time you are born until after puberty, to select the most efficient configuration that will require minimal GC.

[1] http://arxiv.org/abs/quant-ph/0502072
[2] https://en.wikipedia.org/wiki/Synaptic_pruning

Name: Anonymous 2013-12-02 2:58

>>21
I'd love to implement a system where data that fell off too many levels of cache was simply thrown away. Got a circular reference dependency? No fucking problem! Haven't accessed this table of the first 100 million primes in 3.2 seconds? Well, it would probably be easier to regenerate them than to keep them around much longer! Lost data that was obtained from user input? Ask the user to repeat themself.

Don't change these.
Name: Email:
Entire Thread Thread List