News for hackers. Stuff that matters.
Re:Is reference counting slower than GC? by IshKebab on Tuesday May 24, 2016 @07:26AM (#11760604)
What about how reference counting is done in languages like C++ and Rust? I.e. you explicitly make a value reference-counted, usually for large values (an entire class for example). Small values like ints are copied.

That seems like the best approach to me. Plus you can use RAII which is a far bigger advantage than any minor speed differences.

Re:Is reference counting slower than GC? by pjmlp on Tuesday May 24, 2016 @08:01AM (#11760812)
RAII is also possible in GC languages, just done differently.

If the language supports macros or trailing closures, you can somehow have similar approaches to RAII handle classes.

    with-database {
       // connection is only accessible here
    }
    // connection is now closed and gone

    with-file {
       // file is only accessible here
    }
    // file is now closed


    with-mutex {
       // mutex guarded resource is now visible here
    }
    // mutex is now released, regardless of possible errors


    with-native-memory {
       // able to use an OS memory block
    }
    // OS got the memory back