3 ms·
I am not trying to personally attack you here, but most times when people say something like this, what they are actually saying is: "I think I am accomplishing
by hobofan 9y ago
I am not trying to personally attack you here, but most times when people say something like this, what they are actually saying is: "I think I am accomplishing the same thing in C++, but by not facing (and solving) the problems, I am actually creating a program with nasty hidden bugs, that might or might not blow up in my face later".
- CJefferson 9y agoOn the other hand, a buggy C++ program is still better than no rust program.
- vvanders 9y agoHaving had to track down memory data races in a production C++ codebase I'm not sure that I completely agree with your assessment.
- baq 9y agoI've once spent quite a few hours debugging a dangling pointer that wasn't zeroed after delete and was written to which might or might not have corrupted a piece of lua interpreter's state. fixing that felt good. the preceding 24 hours, not so much.
- vvanders 9y agoYup. Data races are particularly nasty because any print statements or debug tracing can trigger a memory fence/reorder and make the problem disappear. Nothing more frustrating then adding a printf only to see the issue no longer manifest.
- drb91 9y agoTrivially false: buggy autopilot software is, many times, worse than no autopilot software if the bug is “blow up immediately”. Some problems are worth the time to solve them.
- lurr 9y agobut I'm not writing autopilot software and rust isn't going to save you from everything.
- CJefferson 9y agoOk yes, I wouldnt write an autopilot in C++. However, for example, on the average desktop or mobile app, it's not clear to me(yet!) it is worth the pain of writing in rust.
- bbatha 9y agoFor the average desktop or mobile app it’s rarely worth it to write in any language with manual memory management.
- lurr 9y agoNo, it's more "I know the lifetimes are right, but I can't figure out how to convince the compiler. I give up, I'm just going to go write it in C++". I'm not the only one to make such comments. They made sure to try and address this in v2 of the book. It still sucks.
- vvanders 9y agoIn that case RefCell[1] is the right approach. I use it a ton with C callbacks where like you said you can't get the compiler to understand lifetimes. You get the added bonus of Rust validating the lifetime at runtime and catching any regressions. In the rare case where the lifetime check is too expensive you're free to turn the types into pointers and use an unsafe block, which gives you the exact same constraints as you have in C++. [1] https://doc.rust-lang.org/std/cell/index.html https://doc.rust-lang.org/std/cell/index.html
- steveklabnik 9y agoSorry that you had this experience. If you have the time, any concrete specifics about things would be helpful.