Hacker News new | past | comments | ask | show | jobs | submit login

I've been following dioxus with interest despite not having a chance to use it yet.

However I'm a bit perplexed with the solution to remove lifetimes [0]. Isn't it a poor's-man GC? What was the performance impact?

[0]: https://crates.io/crates/generational-box

Side-note: `[generational-box](https://crates.io/crates/generational-box)` link is broken




It is poor man's GC, but the memory semantics are exactly the same as the previous version. Since `use_hook` owns a value for the lifetime of the component, that value is dropped when the component drops. All signals still `use_hook` so their lifetimes are the same. No performance impact whatsoever since we generally discourage calling `GenerationalBox::new()` outside of use_hook.

Now if you spammed `GenerationalBox::new()` in a loop or something, yeah, your garbage will exist until the component drops. But most of the time folks will just push/pop from a Map or a Vec and regular memory semantics apply.


>However I'm a bit perplexed with the solution to remove lifetimes [0]. Isn't it a poor's-man GC?

This is essentially just ARC: https://en.wikipedia.org/wiki/Automatic_Reference_Counting


Rust's Arc is like ARC, this is more like a generational pool of Box<dyn Any>.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: