Get the latest tech news
Want to Unlock Performance and Clarity? Use Strong Types
! Christian Eltzschig - 01/06/2024 cpp rust clean-code performance C++ and Rust are strongly typed languages, meaning whenever you declare a variable, you must either explicitly specify the variable or you do it implicitly by assigning a value of a specific type. The type of the variable also comes with a specific contract.
When defining a function input argument as uint32_t, we never need to verify that the user accidentally gave us a negative number or a string. This method returns an optional value that contains either a valid UserName object or nothing when the user name contract is violated. Because whenever one has a call chain where those arguments are forwarded to other functions, especially when they are not directly under your control, the same semantical verification has to be performed.
Or read this on Hacker News