@Gankra Rewriting the old code is also almost guaranteed to introduce new bugs, just not of the memory corruption kind.
Top-level
8 comments
@tedmielczarek @Gankra That just means you haven't found the new ones yet. Also, nothing stops you computing an invalid index in Rust. Simply translating the code won't remove the bugs, only limit their consequences (which isn't a bad thing). @mansr @tedmielczarek "i ported the code faithfully and now it constantly crashes on tripped assertions" tends to result in a lot of bugs being removed :) (also faithfully porting the C code is impossible anyway because of the curse of integer promotion and the like... which is pure upside to lose in the translation and will probably randomly remove several bugs) @Gankra @tedmielczarek Those assertions will only be tripped if your testing covers those cases, which it probably doesn't, or you would have already found the bugs. There is also no guarantee that fixing type mismatches won't add bugs as well as remove some. I'd even say it's quite likely, having seen the mayhem caused by people "fixing" compiler warnings in C code without understanding it properly. @Gankra @tedmielczarek Don't get me wrong, built-in buffer overflow prevention is great, but wholesale code rewrites are much more risky than people seem willing to admit. |
@mansr @Gankra my experience with rewriting existing code (C++, Python) in Rust has overwhelmingly consisted of finding latent bugs in the original code.