Re:What is Rust and why is it so popular?
by zozbot234 on Tuesday January 21, 2020 @01:06PM
(#22109538)
> Rust-the-language doesn't know anything about allocations
AIUI, Rust knows more about allocations than it should, since it's still limited to a single global allocator, and Box<> (which relies on that global allocator) is implemented via compiler magic and cannot be supplemented by equivalent library code. If Rust supported "pluggable" allocators in some fashion, fancy features (including heap compaction, although I find that a bit dubious TBH) might become easier to implement.
Re:What is Rust and why is it so popular?
by steveklabnik on Tuesday January 21, 2020 @01:45PM
(#22110014)
Global allocator is a standard library concern, not a language concern, and Box is magic in only one tiny way that doesn’t actually have to do with allocation. Eventually that will be available to other libraries too.
Re:What is Rust and why is it so popular?
by shepmaster on Tuesday January 21, 2020 @01:22PM
(#22109743)
> If Rust supported "pluggable" allocators in some fashion
It's coming, but it's still unstable and being actively developed
Re:What is Rust and why is it so popular?
by Ar-Curunir on Tuesday January 21, 2020 @01:10PM
(#22109600)
`std` data structures that are generic over type of allocator are in the works.
1. Rust-the-language doesn't know anything about allocations, so strictly speaking, it cannot. Furthermore, without a GC, it's unclear how it could in the first place, given that a compaction would invalidate all pointers to that memory.
2. Certainly not to the same degree as the JVM, given that there's nothing inherently to inspect, like there is in languages with a runtime. You can instrument your own application, but that does mean doing the work yourself, and you only get as good of results as you put in in the first place.