4 ms·
> The "safe" solution recommended by the rustaceans was to use integers as references to the data in a vec or hashmap. What ? Box, Arc (and weak) are exactly m
by Fiahil 4y ago
> The "safe" solution recommended by the rustaceans was to use integers as references to the data in a vec or hashmap.
What ? Box, Arc (and weak) are exactly made for this.
- ajross 4y agoBox doesn't solve the problem of cyclic references. And telling people they need to eat the overhead of a per-object reference count and/or weak pointer double-dereference just to write a list that can delete items in place is a pretty tall order for a language that claims to be high performance. No, this is genuinely a big hole in the expressive space of the language. Not a lot of apps really need to do a ton of manual pointer work implementing non-trivial data structures, but some do, and it kinda sucks in Rust.
- Fiahil 4y agoAs other pointed out, if Arc is not an option, then a well encapsulated raw pointer might just be what's needed. I've implemented several of such data structures, there is not that many tradeoffs available : safe and easy, or unsafe and fast. The unsafe parts are still much better than raw C. I don't agree that the language and ecosystem is missing a "big piece". Everything is already there.
- ModernMech 4y ago> a pretty tall order for a language that claims to be high performance. Doing this in Rust is still going to be orders of magnitude faster than many other languages. Maybe not C/C++, but then again if you’re chasing pointers in a list maybe squeezing every ounce of performance you can isn’t the #1 priority for the given application. The industry consensus is shifting to the idea that being #1 in security at the expense of being #2 or #3 in performance is a fine trade off.
- ajross 4y ago> The industry consensus is shifting to the idea that being #1 in security at the expense of being #2 or #3 in performance is a fine trade off. Is it? That's where Java was 20 years ago.