4 ms·
I keep waiting for the announcement that some propeller-head has implement the Rust borrow checker as a template metaprogram, with the caveat that nothing large
by smitty1e 5y ago
I keep waiting for the announcement that some propeller-head has implement the Rust borrow checker as a template metaprogram, with the caveat that nothing larger than "Hello, world." compiles within a month.
- nyanpasu64 5y agoGoogle tried and failed, and they didn't even try to model reborrowing (a hidden gotcha in Rust): https://docs.google.com/document/u/1/d/e/2PACX-1vSt2VB1zQAJ6JDMaIA9PlmEgBxz2K5Tx6w2JqJNeYCy0gU4aoubdTxlENSKNSrQ2TXqPWcuwtXe6PlO/pub https://docs.google.com/document/u/1/d/e/2PACX-1vSt2VB1zQAJ6...
- smitty1e 5y agoFor one quick read, that was a well-written exposition. In short, the type system in C++ just can't quite fully express the requirements. What I didn't see Google do in that article was trot out any template metaprogramming artillery: https://www.boost.org/doc/libs/1_78_0/?view=category_metaprogramming https://www.boost.org/doc/libs/1_78_0/?view=category_metapro...
- tialaramex 5y agoYou'd probably be happy with the people doing constexpr shenanigans. A whole bunch of terrible behaviour in C++ is defined away during constexpr expansion (e.g. since none of this is really happening at runtime you can't very well have "undefined behaviour" when there is no behaviour at all) so if you can find a way to write everything as constexpr you get a much "safer" language. e.g. buffers don't really exist, so therefore buffer overflows don't compile. There are a LOT of caveats when people take this beyond trivial, not least that the compiler diagnostics are mostly useless because the compiler often isn't sure exactly why what you're doing is nonsense, only that it is nonsense. Hey, it wouldn't even have told you that the code was nonsense if it wasn't constexpr - it would just spit out a program that's also nonsense, so that's a win right?
- einpoklum 5y agoC++ has gone down a different path, and reasonable one if I can say so myself. Bjarne Stroupstrup said: > I don't like garbage. I don't like littering. My ideal is to eliminate the need for a garbage collector by not producing any garbage. That is now possible. And indeed, with modern C++ idioms you can avoid leaks at the static analysis level, avoid buffer overflows by simply not passing raw pointers around, etc. So no borrow checker / garbage collector necessary. For a little more elaboration on this point, see: https://stackoverflow.com/a/48046118/1593077 https://stackoverflow.com/a/48046118/1593077 Is it 100% bullet-proof? No, but then, Rust needs some unsafe parts too.