Comment by lordofgibbons
16 hours ago
Pardon my ignorance, but doesn't a byte-by-byte output recreation of the C++ code in Rust defeat the whole purpose of using Rust? For one, would it be idiomatic Rust anymore? Also, if there's a (non-memory related) vulnerability in the C++ code, would it be possible for that to be introduced in Rust too?
The impression I get from the article is not that the compiled code of each implementation produces the same object code, but that when the implementations are run with the same inputs, they produce exactly the same output — that is, the same JS VM bytecode.
That matches my understanding too.
If they had developed a technique to get a modern C++ compiler and rustc to generate exactly the same output for any program (even a trivial one) I think that would be huge news and I would love to see all the linker hacking that would involve.
I've looked at the code from the PR. It seems to use safe types and standard idioms like pattern matching, so at least at first glance it looks like Rust.
It could have been worse. C++ code naively converted line-by-line to Rust typically results in weird and unsafe Rust, but in this case it seems they've only been strict about the results being the same, not the structure of the implementation.
Rewrites have a very high risk of introducing regressions. Trying to fix bugs while rewriting will only make things harder, because instead of simply comparing outputs exactly, you'll have to judge which output is the right one. If you let the behavior significantly diverge during the rewrite, you'll just have two differently buggy codebases and no reference to follow.
It's much easier to make a bug-for-bug compatible copy, and fix bugs later.
Once you get a byte-by-byte duplicate, you can start refactoring into idiomatic Rust. Convert pointers to references, rip out unsafe blocks, and let Clippy go ham.
Add the fact that AI is writing the rust code...