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

Yes! The sanitizers have been a huge game changer for me.


Having used sanitizers to find a couple C++ bugs I am convinced that Rust is a better solution to that problem. I would never have found the C++ issues without extra tooling, so just use Rust, learn the rules and let the compiler make you write correct code. To clarify, yes ASAN is awesome but using a language where you don't need it is better.


How does rust help fix bugs in a C++ code base?


When there's no more C++ there will be no bugs in the C++ code base ;-)

j/k, though I've fixed memory bugs, overflow, use after free, etc. written by people much smarter than me. without static analyzers, valgrind, and afl its possible that some would still exist nearly a decade later.


Any custom allocator in Rust will use a lot of unsafe code.


I would hope all the analysis Rust does can inform the choice of built-in allocator so you dont need to roll your own.

Also, any custom C++ allocator is going to contain a bunch of unsafe code too.


I'm not sure what you mean by "all the analysis"; by default Rust just calls malloc.

It's true that a C++ custom allocator will have lots of "unsafe" code, but this is really where C++ shines. The tooling is more complete, the aliasing rules are better documented and understood, the language fights you less, the stdlib has explicit support, it is easier to control the codegen. Rust cannot bring its strengths to bear on this sort of problem.




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

Search: