Choosing the Right Integers
I am generally in the camp of maximally explicit and consistent semantics for integer types. The old C-style types (short, int, etc) and related promotion rules was the source of numerous bugs in practice, particularly when porting code across architectures with different type models. While not convenient in C, in C++ there is almost unlimited ability to define new families of integer types that follow their own rules.<p>I don&#x27;t follow the argument for using signed integers outside of contexts where a negative value is valid. In code bases that always use unsigned integers for values that cannot be negative (common in C++), the MAX value is treated as a sentinel. This extends the range of valid values versus signed types, which is sometimes useful, and there will never be undefined behavior (decrementing zero generates the sentinel, for example).<p>The infinite loop example often given for why to use signed integers doesn&#x27;t happen in practice for &quot;default unsigned&quot; code bases because that is not idiomatic expression of that case -- and this case will come up even in code bases that are default signed. Writing loops like this is often a code smell.