3 ms·
From the end of the safety document: > Overall, Carbon is making a compromise around safety in order to give a path for C++ to evolve. C++ developers must be c
by ansible 4y ago
From the end of the safety document:
> Overall, Carbon is making a compromise around safety in order to give a path for C++ to evolve. C++ developers must be comfortable migrating their codebases, and able to do so in a largely automated manner. In order to achieve automated migration, Carbon cannot require fundamental redesigns of migrated C++ code. While a migration tool could in theory mark all migrated code as unsafe, Carbon should use a safety strategy that degrades gracefully and offers improvements for C++ code, whether migrated or not.
> That does not mean Carbon will never adopt guaranteed safety by default, only that performance and migration of C++ code takes priority, and any design will need to be considered in the context of other goals. It should still be possible to adopt guaranteed safety later, although it will require identifying a migration path.
That's very interesting and pragmatic. It would be interesting if they can eventually come up with the same level of safety guarantees via a different path than Rust's borrow checker.
-------------
Since one of their goals is to automatically translate modern C++ to Carbon, I do wonder how well that is going to work in general.
I definitely welcome an alternative to C++ that would be easier to read and understand. That would be a benefit to the world.
- jeffreygoesto 4y agoThe borrow checker is a pretty smart solution pushing checks to compile time and have efficient runtime, so yes, it would be interesting to see if there is an even better alternative. But you can't beat that kind of safety into an old C++ code base, so I am pessimistic for retrofitting.
- klodolph 4y agoThis is also how Meta got Hack. It's not like PHP is unsafe to begin with like C++, but the language does have a ton of problems, and Meta's massive codebase could only be migrated to another language gradually. Hence, Hack. Better language, better tooling, more productive programmers. Note that unlike Carbon/C++, Hack is backwards-compatible with PHP. So the migration is somewhat more gradual.
- MR4D 4y agoI wonder what would happen if Security became a compiler flag? For instance, just like the -O1 or -O3 flags work for optimization, something like a -S1 or -S3 would be really useful. To me, there are lots of times when I just need to get an idea into code. Then there are times when I need to make sure that code just works™. Having different compiler flags would really make that nice, and for devops, allow anything pushed to production have to complete a -S3 successfully first.
- pjmlp 4y agoYou already have them, true it is more than one and isn't bullet proof, still it is way better than not using them.
- MR4D 4y agoSorry, I wasn’t as clear as I meant to be. I was specifically thinking about things like Rust lifetimes being a compiler warning level instead of an absolute.
- palata 4y agoYou mean that you want your compiler to say "I know that this will sometimes fail, but I'll let you burn yourself unless you enable a flag"? Should it also have a flag to say "Told you!" when it happens? xD