Code Review
Code Review
Posted Nov 13, 2025 21:45 UTC (Thu) by Vorpal (guest, #136011)In reply to: Code Review by clugstj
Parent article: Rust in Android: move fast and fix things (Google Security Blog)
> Code review is a time-consuming and high-latency part of the development process. Reworking code is a primary source of these costly delays. Data shows that Rust code requires fewer revisions. This trend has been consistent since 2023. Rust changes of a similar size need about 20% fewer revisions than their C++ counterparts.
I read that as "code submitted for review has fewer issues to begin with".
That would certainly mirror my own subjective experience of coding in Rust: once I get the compiler to accept my code (which takes longer than in C++ sometimes), it usually works correctly on the first try, or only has some trivial logic bug ("oops, I forgot to actually write out the result to a file").
My educated guess as to why this is, is that some of the non-memory safety features of Rust help: in particular sum types and linear types (well, affine types really).
Sum types is "enums with payload" or "type checked tagged unions" for those who come from other programming languages.
Affine types is about functions transferring ownership of a value as a parameter in a function call. You can no longer use it after that.
Both of these together allow designing APIs that are harder to use incorrectly. Sum types by making it impossible to represent invalid state. Affine types help in many ways, such as making it possible to statically represent the state of an object in the code ("if I'm here in the code I know statically that the object must be in this state, and only then am I able to call this function on it")
One example of the latter is in embedded Rust where it is used for configuring GPIO pins: you have to fully configure the pin before the methods for writing/reading are exposed, and only those methods that are compatible with the configuration are available. Ownership is here also used to ensure two different parts of the code can't use the same pin in conflicting ways.
