3 ms·
> And at that point why not just use Rust See my sibling comment. Using Rust implies many more changes than just moving code to an incompatible-but-close versi
by jfkebwjsbx 6y ago
> And at that point why not just use Rust
See my sibling comment. Using Rust implies many more changes than just moving code to an incompatible-but-close version of C and C++ that adds lifetime annotations and unsafe blocks. Compare it with the Python 2/3 split vs. rewriting all your Python 2 code to, say, Ruby.
Then there is the OOB issues too, like using another build system, a single compiler based on LLVM, etc.
- cptroot 6y agoGiven the degree of changes required in some codebases, I think some teams would rather treat it as a rewrite job. Even moving large enterprise codebases from python 2 to python 3 is taking so long they had to push that deadline back years. Given the distance you'd have to cross to push an older C++ codebase to something with similar guarantees as Rust, I don't know if any company would voluntarily cross that gap.
- DougBTX 6y ago> adds lifetime annotations and unsafe blocks Worth noting that the vast majority of lifetime annotations in Rust are “elided”, i.e. inferred by the compiler. I’d say that a successful “safe C” compiler would accept any existing C code that never invokes undefined behaviour, without a runtime performance penalty.
- nicoburns 6y ago> I’d say that a successful “safe C” compiler would accept any existing C code that never invokes undefined behaviour, without a runtime performance penalty. That's unfortunately what's not possible. The C source code doesn't contain enough information to prove safety (a lot of real world C code depends on invariants that happen to be true at runtime, but aren't provably true at compile time)
- DougBTX 6y agoYes, it probably is impossible. On the other hand, C programmers are asked to write code which doesn't invoke undefined behaviour otherwise their code can break in unpredictable ways, so either we just don't have sufficiently good checking algorithms yet or it is impossible for them too.