News for hackers. Stuff that matters.
Re:Rust: Dropping heavy things in another thread can make yo... by Reelin on Saturday May 30, 2020 @02:35PM (#23363460)
My understanding is that finalizers are special cased for a generational GC, have a tendency to introduce significant overhead, and (as with any GC scheme) generally run at unpredictable times. My impression is that RAII idioms are strongly discouraged in conjunction with most GC ecosystems.
Re:Rust: Dropping heavy things in another thread can make yo... by tsimionescu on Sunday May 31, 2020 @08:13AM (#23369039)
Actually, RAII idioms are generally encouraged, but finalizers are not. For the rare few classes that hold resources in GC languages, the Resource is usually Acquired at Initialization as well, and released in a special method (IDisposable.Dispose() in C#, AutoCloseable.Close() in Java). There is also usually some special syntax for automatically calling this syntax when the object exits some scope, though that scope usually has to be declared by the user (using(), try-with-resources, with() in Python etc.).

The biggest difference I know of is that the 'holds-resources' property does not propagate automatically like it does in C++. It's not that hard to always remember to call using(file = new File()) [...]. However, it's much easier to forget that you have a File field in your class which you initialize in the constructor, and so your class must itself be declared IDisposable/AutoCloseable etc.

Re:Rust: Dropping heavy things in another thread can make yo... by Reelin on Sunday May 31, 2020 @07:17PM (#23373893)
This is a really good point. I had completely overlooked various deterministic resource cleanup idioms as being equivalent to RAII in all but name.