2 ms·
There's a safe and sane language subset struggling to get out of "modern C++". The essence is following the Rule of 3/5/0, adopting value semantics, explicit ow
by bluetomcat 3y ago
There's a safe and sane language subset struggling to get out of "modern C++". The essence is following the Rule of 3/5/0, adopting value semantics, explicit ownership via unique_ptr/shared_ptr, resources wrapped as RAII objects. The syntax and feature space is certainly crowded and abused, but playing with the borrow-checker is an entirely different game.
- MaxBarraclough 3y agoLate to the party, but: this unfortunately doesn't seem to be true. There's no subset of C++ (or C for that matter) which is both safe and practical to use. This is why, say, the Chromium folks are seriously looking at adopting Rust. Same goes for the Linux kernel and their adoption of Rust, although of course that's a C codebase. To rework an old comment of mine: [0] There is no subset of C++ which is both safe and practical for real use. The MISRA C++ subset isn't enough to provide solid assurance of the absence of undefined behaviour, for instance. For that, you need a full-bore formal verification system, akin to that of the SPARK Ada language. This is in sharp contrast to Rust, where there really is a subset which is safe 'by construction' (called Safe Rust). [0] https://news.ycombinator.com/item?id=27605144 https://news.ycombinator.com/item?id=27605144
- Yoric 3y agoYeah, I've tried to find this mythical subset. I handwaved my way around most of the difficulties, but I think that it exists. However, I'm not convinced that C++ developers are going to enjoy it. In particular, the subset I could come up with is much less expressive than Rust. I've written down some of this at https://yoric.github.io/post/safety-and-security/ https://yoric.github.io/post/safety-and-security/ .
- stefan_ 3y agoThat's my problem when people talk of C++ as if it was a sane, consistent language with a common style and doctrine like C#. You could get anything between C with classes and turbo template metaprogramming header only Boost specials. Job postings with C++ should probably include an example source file..