3 ms·
> At the cost of making the use of the resulting heap significantly slower and larger than if you just wrote the thing in Java to begin with, though! Lower thr
by creata 1y ago
> At the cost of making the use of the resulting heap significantly slower and larger than if you just wrote the thing in Java to begin with, though!
Lower throughput, probably. But it introduces constant latency. It has some advantages over doing it in Java:
* You're never going to get latency spikes by adding a counter to each allocation slot.
* If you really want to, you can disable them in release builds and still not give up memory-safety, although you might get logical use-after-frees.
* You don't need to use such "compromises" for literally everything, just where it's needed.
> It starts from a marketing position of "Safety With No Compromises"
I haven't seen that marketing, but if it exists, sure, it's misleading. Yes, you have to compromise. But in my opinion, the compromises that Rust lets you make are meaningfully different from the compromises in other mainstream languages. Sometimes better, sometimes worse. Probably worse for most applications than a GC language, tbh.
- ajross 1y ago> * You're never going to get latency spikes by adding a counter to each allocation slot. The suggestion wasn't just the counter though. A counter by itself does nothing. At some point you need to iterate[1] through your set to identify[2] the unreferenced[3] blocks. And that has to be done with some kind of locking vs. the unrestricted contexts elsewhere trying to do their own allocation work. And that has costs. Bottom line is that the response was isomorphic to "That's OK, you can work around it by writing a garbage collector". And... yeah. We have that, and it's better than this nonsense. [1] "sweep", in the vernacular [2] "collect", in some idioms [3] Yup, "garbage"
- creata 1y agoNo, sorry, in case I wasn't clear, I was talking about manual deallocation. I wasn't talking about a garbage collector. You still allocate and free cells. Here's an example of what I am talking about: https://docs.rs/generational-arena https://docs.rs/generational-arena If you're implementing a tracing garbage collector you obviously don't need any such counters to detect use-after-frees. This is clearly a different compromise entirely to the one made by tracing garbage collection. I'm actually not sure how you confused the two.