4 ms·
But the advantage of that doesn't apply in garbage collected languages, right?
by RivieraKid 6y ago
But the advantage of that doesn't apply in garbage collected languages, right?
- johnfn 6y agoActually, I wouldn't say so. e.g. Rust verifies that only one copy of my data is mutable at any one time. This is actually the kind of thing you'd always want to verify, even with a GC, because having two (say) classes that could mutate the same data instance could become a huge mess. e.g. even in GC'd languages there are libraries to provide immutable data structures because we understand that having multiple writers to data is a mess. The true ideal (for coding ergonomics) is exactly 1 writer, but there was no way to statically verify that.
- saagarjha 6y agoYou'd like to verify this always, but the Rust compiler is limited in that it can only verify this at compile time with proper annotations. As such, it rejects some valid programs.
- saurik 6y agoThat there will exist valid programs which will be rejected is true of all type systems, and that you need "proper annotations" is true of almost all type systems (and if this was worded only slightly more broadly, to discuss "proper structure" or something, it would again be true of all type systems); this shouldn't be considered a theoretical problem unless it accepts invalid programs (though it might be considered a practical problem if it is nearly impossible to correctly structure/annotate a program to make it accepted).
- saagarjha 6y ago> this shouldn't be considered a problem unless it accepts invalid programs I mean, a compiler that accepts no valid programs is problematic is it not? The way that the Rust compiler does its thing does not really work for a garbage collected language, and the comment that I was responding to, which was itself responding a restarting of what I just mentioned, said that you'd want Rust-style verification anyways for those things, which is not really an answer to the question because that kind of thing is not something that Rust can do.