5 ms·
I'm interested in more on this. What can I do in C++ that I can't do in Rust?
by badrequest 3y ago
I'm interested in more on this. What can I do in C++ that I can't do in Rust?
- steveklabnik 3y ago(Not your parent) Many people point to more advanced meta programming, such as variadrics, higher kinded types (though as mentioned GATs advance Rust in this general area), and specialization.
- badrequest 3y agoSteve, your comments are always a welcome surprise, I hope all is well with you and yours. :)
- TremendousJudge 3y agoWrite unsafe code wrapped in layers of those advanced features that half the team didn't even know existed, and push it into production.
- vanderZwan 3y agoAm I the only one who works at a place where things don't make it into production unless at least one other person on the team fully understands the code during review?
- TremendousJudge 3y agoPlenty of people don't, it's the most common thing. Maybe right now you are lucky enough to work in good contitions (that's great!), but are you sure it couldn't happen to you in 10 years? I think the standard tools we use in our profession should work in less than ideal conditions as well.
- vanderZwan 3y agoOh I want my tools to help me, don't get me wrong. I just wonder if all the horror stories I hear are the norm, or just the stories we like to share the most.
- dataflow 3y agoThis is just one example, but moves are always bitwise, correct? So if I want an object to track all users of it in C++, I can just make a smart pointer for it whose copy/move/destruction operations notify the object about each event. How would you do that in Rust? (Similarly, what if I want a relative pointer?)
- remram 3y agoYou can track all of this (things like Rc or Arc do) except move. Relative pointers are possible, depending on what you mean. Making this safe (e.g. preventing users of that type from breaking the relative addressing) is done via the Pin type.
- dataflow 3y ago> You can track all of this (things like Rc or Arc do) except move. Which means you can't track this. Tracking moves is fundamental here. > Relative pointers are possible, depending on what you mean. Pretty sure they're not possible in the sense I mean, for the same reason as above - you need custom moves for this. I'm referring to a pointer (not an offset; a pointer) that automatically adjusts itself when copied or moved. So that it always points somewhere N blocks before/after itself. These are just two examples, to get the point across that Rust actually lacks some capabilities (since somehow that surprises people). You can find more.
- remram 3y ago> Tracking moves is fundamental here. I mean, arguably. If it is fundamental for your hypothetical use case, then sure, but this is not required for a lot of use cases, like smart pointers.
- dataflow 3y ago> this is not required for a lot of use cases, like smart pointers. Nobody claimed otherwise. The question was what things Rust can't do, not what it can do.