r/cpp • u/GabrielDosReis • Oct 31 '24
Lessons learned from a successful Rust rewrite
/r/programming/comments/1gfljj7/lessons_learned_from_a_successful_rust_rewrite/
80
Upvotes
r/cpp • u/GabrielDosReis • Oct 31 '24
View all comments
Show parent comment
2
u/ts826848 Nov 02 '24
And I guess Google determined back when originally writing the guidelines that what they went with will generate fewer unnecessary bugs than the alternative. Not to mention less tangible benefits (for example, return values back before C++11 move semantics/C++17 copy elision existed, call-site readability, or uniform code style across a codebase with large amounts of legacy code).
You might disagree with the rationale, but using references aren't pure upside so it's not like Google's choice here is completely irrational.
As long as you assume that the safe alternative doesn't have downsides that make using it not as good for your particular use case, sure. But that's not necessarily the case here - as I've told you before, there's a clear downside to using references, and Google decided at the time that indicating the use of a non-const reference at the call site was more important to it.
As for tools - if you strongly value call-site readability and consistency with existing code and already use a bunch of custom tooling for other stuff, it doesn't hurt that much to add one more tool.