by AntonCTO · 3y ago · 0 comments
Personally, I wouldn't link it directly to rust, but to rewriting. When you develop something, you usually can't account for all future changes that affect performance, design, LOC, robustness, and so on. But with rewrite, you take them all into account. So there is a big chance that rewrite will be superior in many areas. It will probably have the same effect as if they had rewritten it in C++ again.
What I think this note bucks is the concept choosing a secure language to re-implement something in means performance overhead compared to C/C++ code that has had years or decades of work putting into it. It doesn't necessarily argue A or safe B is inherently faster, just that a safe B doesn't imply you should expect it to be safe and slower, just safe.
A C rewrite promising a moderate speedup wouldn't so much be skipped because it was not worth the effort, they are not done because the speedup isn't worth the risk of having to go through all that again.
For example:
"Too many cooks spoil the broth" vs. "Many hands make light work"
"Look before you leap" vs. "He who hesitates is lost"
'It's just a few bad apples" vs "one bad apple spoils the barrel"
Or "blood is thicker than water" can mean you prioritise family.
But the full saying is actually "blood of the covenant is thicker than water of the womb" and means opposite
However, there are some ways that I'd expect similarly capable programmers are likely to often produce faster Rust code than C++ and much fewer ways I'd expect the opposite, so it's not a surprise when this work results in a small unlooked-for performance improvement.
e.g. https://lemire.me/blog/2023/04/27/hotspot-performance-engine... which was on HN today.
Andrew Kelley (zig) did a whole talk on data oriented design a while back talking about the same thing. And Casey Muratori is also talking about it a lot right now, and with good reason.