News for hackers. Stuff that matters.
Re:Single Page Applications using Rust by ragnese on Tuesday August 11, 2020 @05:33PM (#24126241)
One of the things I like about non-managed languages is the ability to have true destructors. Releasing resources is awkward at best in Java, et al.
Re:Single Page Applications using Rust by navaati on Wednesday August 12, 2020 @12:09PM (#24133466)
Note that you can have linear types (which is what gives you what you're talking about) in managed languages. You can have them as an extension in Haskell for exemple.

Rust is the only mainstream-ish language to really use them, though.

Re:Single Page Applications using Rust by ragnese on Wednesday August 12, 2020 @12:46PM (#24133884)
Rust uses a mixture of affine and ... "regular"? types. My understanding is that affine is a looser version of linear because the type doesn't have to be consumed.

You can have dtors in non-affine types (types that implement the Copy trait) in Rust as well. I'm really only talking about C++ style destructors. Those don't require linear or affine types. But, I agree, that in a managed language, having a linear type is one way to get predictable destructors to run.

Strangely, Swift has deinit{} for its class types (ref-counted), but not for its struct types (value types).

Re:Single Page Applications using Rust by steveklabnik on Wednesday August 12, 2020 @02:38PM (#24135280)
You cannot implement Drop for a Copy type.
Re:Single Page Applications using Rust by ragnese on Thursday August 13, 2020 @08:09PM (#24151557)
Fair enough! I never wanted to implement Drop on a Copy type, but I assumed you could.