Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you try to strictly enforce memory safety in C++, you end up with code that looks a lot like Rust. But the Rust compiler will fail to compile code that has memory-safety issues (outside of unsafe blocks), while your C++ compiler will happily ignore them.


The challenge is that the Rust compiler will fail to compile many codes that are strictly and provably memory safe but fall outside Rust’s narrow model of “memory safe”, and which are required for performance reasons. You’d have to wrap most of the code in unsafe blocks. In C++17 you can directly write type infrastructure that transparently enforces memory safety models that Rust doesn’t grok, which is a pretty nice feature.

Many people underestimate what is possible using C++ these days. Complex for sure, but also very powerful.


> Many people underestimate what is possible using C++ these days. Complex for sure, but also very powerful.

And that's the problem. There are very few true C++ experts, and most people will run into these issues as a matter of course.

This just feels like a reduction to the usual: if you are perfect, you will write perfect code, and never have memory-safety bugs. Thanks, but I'm not perfect, and I'd rather write in a language with a compiler that rejects programs with memory-safety bugs.

And yes, that does mean sometimes it'll reject some programs that are perfectly ok, but the Rust borrow checker is getting better all the time, and sometimes you just have to accept being hamstrung a little for the greater good.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: