3 ms·
"This is why it's time to move to Rust" I'm not sure this a good chapter in that dialog. There are simpler (simpler in the sense 'less complected' and not easi
by fsloth 11y ago
"This is why it's time to move to Rust"
I'm not sure this a good chapter in that dialog. There are simpler (simpler in the sense 'less complected' and not easier) ways to handle resource management in C++ than this default ballet.
The example is clever C++ code. Most of the time clever C++ is bad because the stupid verbose way would be easier to understand and maintain. So, before demonstrating some intricate template scheme or inheritance trick there should be a good reason presented why it makes things simpler.
I agree on what you said but this example is a poor device if we are discussing code in a production setting.
- kabdib 11y agoRight. Several million lines of C++ says that we can't just "move to Rust," and a bunch of engineers doing C++ every day also means that someone starting something new in Rust will be looked upon with suspicion and worry, even if Rust will make the engineering staff stop hating life. Local maxima are a bitch.
- quicknir 11y agoFull disclosure: I'm the blog author. If you're claiming that the verbose way is just writing out the special functions, then I can assure you that it is not easier to maintain. If you are saying that the class in question could simply write a nested class that wrapped unique_ptr and had the correct copying behavior, maybe, there are arguments for both. This example is fully intended to be solid code for production use, not primarily to be "clever".
- fsloth 11y agoHi! I have nothing against the pure technical aspects of your article. I originally answered to the poster who said this was a good example why Rust was better and my analysis was written from that point of view. To me this was a poor comparison in the general sense since one can write production C++ using just copy-by-value, RAII semantics and stl containers and handling exceptions by letting the program terminate. "If you're claiming that the verbose way is just writing out the special functions, then I can assure you that it is not easier to maintain." I suppose I found this example lacking in the comparison-to-rust sense precisely because it invented this complected system that needed patching over. While real life systems often evolve through neglect and haste into piles of spaghetti this cannot be used as a direct evidence against a specific language in particular since it is more of a psychological and organizational rather than a language problem.