News for hackers. Stuff that matters.
Re:Removing Garbage Collection from the Rust Language (2013) by Someone on Monday September 11, 2023 @11:42AM (#37468953)
> If a programming language can tell when a variable goes out of scope, or its lifetime ends

Whether a variable goes out of scope is trivial in many languages. The problem is with determining whether the lifetime of a value ends.

For example:

    func foo(items, moreItems) {
        b = new bar()
        if coinflip() {
            items.append(b)
        }
        if coinflip() {
            moreItems.append(b)
        }
        // ‘b’ goes out of scope here, but its value
        // may live on inside ‘items’ and/or moreItems
        // and will have to be destroyed when it’s no
        // longer stored in either.
    }
In general, once you allow for dynamic allocation and references that can be copied (so that multiple objects ‘know’ of the allocated object), it can be very difficult to determine exactly when the last reference to such an object ceases to exist.
Re:Removing Garbage Collection from the Rust Language (2013) by dcuthbertson on Wednesday September 13, 2023 @07:08AM (#37495135)
Yes, I agree that determining the lifetime of a value is the hard part. I wrote "... and use that information to automatically release allocated memory, ..." to imply the language got lifetime detection right.