3 ms·
For me it was the web-of-pointers strategy I had to unlearn. A child object keeping a pointer to its parent is misery in Rust. It forces you to either make th
by hyperman1 4y ago
For me it was the web-of-pointers strategy I had to unlearn. A child object keeping a pointer to its parent is misery in Rust. It forces you to either make the child completely independent or really prove the parent will be around until the child disappears.
90% of the time this is dumb overhead, but 10% of the time it found a bug in some edge case, so I learned to appreciate it as a tough teacher, and my designs got better for it.
- deleted 4y ago[deleted]
- FpUser 4y ago>"90% of the time this is dumb overhead, but 10% of the time it found a bug in some edge case, so I learned to appreciate it as a tough teacher, and my designs got better for it." Sounds kind of like Stockholm syndrome
- atoav 4y agoAnd you sound like you are part of the reason why we still have exploitable null-pointer bugs in 2022. Imagine a structural engineer that would say "all that static and dynamic analysis is dumb overhead 90% of the time, so I am going to skip it". Imagine an electrical engineer who would go like "all these wire gauge calculations are exhausting, 90% of the time my installations don't catch fire" Seriously, I sometimes wonder what is wrong with the whole field of software development.
- FpUser 4y agoNothing is wrong. Same shit as in any other area. It is a usual trade-off between what you pay and what you get in return, some of it highly politicized.
- philosopher1234 4y ago> designs got better for it. What is better about them?
- pimeys 4y agoWe solved this with flat vectors and just sharing index values in cheap walker objects. It is much nicer to work with compared to arc/weak pointers. Code here: https://github.com/prisma/prisma-engines/tree/main/libs%2Fdatamodel%2Fparser-database https://github.com/prisma/prisma-engines/tree/main/libs%2Fda...
- int_19h 4y agoHow is this fundamentally different from raw pointers?
- dralley 4y agoNot OP It serializes better, it's memory safe, it can be much faster in performance terms, you can get better memory usage if you're holding a lot of "pointers" because the indexes don't need to be 64 bits.
- int_19h 4y agoBut you lose all ownership tracking / safety that Rust is famous for. I just can't help but wonder what it means for that paradigm, when the most popular answer to "how do I model my entities in safe Rust" is basically "backdoor the safety".
- pflanze 4y agoWhich way did you go, (1) not use pointers from child to parent (functional programming approach), or (2) kept using such pointers but made it work? Your first paragraph sounds like (1), but the second sounds like (2). If it was (2), it sounds like you made it work without unsafe code? Can you share some code?