Hacker News new | ask | show | jobs
by estebank 1423 days ago
> When using Rust, one has to use discipline to avoid this bug: use IDs into a hash map, or generational indices, or Rc<RefCell<T>>. Each has its own performance hit, but that hit can be worth it to prevent privacy bugs.

The perf hit of generational indices/arenas is minimal, and the cost of Rc<RefCell<T>> is still lower than complex GCs without JIT.

> In the GC'd/RC'd language, this would still be a bug, but it wouldn't cause any mixups between different users' data.

I've seen that exact bug in systems written in all kinds of languages.

And for what is worth, keeping a Vec<UserAccount> in memory only works on single instance services, anything beyond that and you'd have to deal with cache invalidation as well.