3 ms·
It seems like this is more a critique of the design of the standard library than the language itself. You could create a library that behaved similar to the Rus
by tines 6y ago
It seems like this is more a critique of the design of the standard library than the language itself. You could create a library that behaved similar to the Rust version, offering the same compile-time safety checks, in C++. I'm sure it would also be equally trivial to parallelize the C++ version with Boost or some other library (except that you wouldn't get the nice error about the unlocked hash map, so I have to hand it to Rust on that point).
I think the author's problem is that C++ even allows you to do it the wrong way in the first place, but I'm sure that you could design an unsafe FS API with Rust as well (though it might be a little harder).
- arka2147483647 6y agoDo you truly feel that the standard library is not part of cpp? In general, i think a lot of valid criticism of cpp is dismissed with ”But you could do it correctly with X” Perhapse, but if everything is a special case, what does that say about cpp?
- beached_whale 6y agoThe article does seem to nitpick a C++ design and then highlight the same feature in Rust. The way getline failed there is not "accidental" but the design of fstreams/getline, so that "less-careful" programmers don't have those corners here. Thing is, all of the solutions to the issue here would be a real PITA if done as one function as both examples are. That is why example code often skips checks to allow the point of the article to be highlighted and not hide it. This is more true with filesystems related code as filesystems are not reliable. One example of how many corners filesytems have is the unit tests for sqlite, they are amazing.
- deleted 6y ago[deleted]
- imtringued 6y agoSure, you're right. In practice nobody actually does what you're saying though.