4 ms·
What exactly do you mean by compile time GC? Various techniques like compiler-optimized GC have been around for a while. If you are looking for mainstream stuff
by ribit 5y ago
What exactly do you mean by compile time GC? Various techniques like compiler-optimized GC have been around for a while. If you are looking for mainstream stuff, Apple’s automatic reference counting for Objective C comes to mind (has been shipping since around 2009)
- nu11ptr 5y agoI mean that Rust knows exactly when something will be deallocated at compile time due to its lifetime system (for things that are single ownership, Rc/Arc excluded). In contrast, ARC does compiler assisted increments/decrements if I recall, but still uses runtime ref count to know if something needs deallocation.
- ionicgiraffe 5y agoC++ programmers where selectively implementing borrow checkers at runtime decades ago (see library omnetpp as an example). Moving those borrow checkers to compile time with templating is possible (but people did not do it because the borrow checking could be disabled after testing and no overhead would be paid neither at runtime nor compile time). That Rust implements borrow checking as pillar of the language I think it is great.
- ribit 5y agoAh, I see. True, Rust has a more restricted model that allows it to track lifetimes more precisely. As far as I know, Clang will omit reference counting if it can be statically determined but of course it has fewer optimization opportunities here. In the end, the two approaches are not entirely dissimilar: ARC uses static analysis to detect dependencies and will fallback to dynamic RC n complex scenarios; while Rust enforces certain rules that only allow most basic dependencies and requires the user to mark these by using dedicated tools.