re: Convince me that types are awesome VIEW POST


Static type systems find certain kinds of mistakes at compile time, which is often orders of magnitude faster than running the code, especially when getting a piece of code to run takes several steps such as clicking around a GUI. I find this a huge productivity boost as they're a kind of mistake I tend to make very frequently. I particularly enjoy algebraic data types in languages like Haskell, Elm and Rust, which can encode a set of states in a way that guarantees validity at compile time while making code more explicit and readable for humans as well.

Regardless of the type system used, I consider explicit type annotations one of the most important aspects of readable code and documentation. I've been getting familiar with some Python code lately and finding a lot of friction in function signatures - if a function doesn't say what type of data it wants to be called with or what it returns, I have to skim through the entire function body or find a call site to figure out how to use it. With type annotations I can get nearly as much information from one line.

code of conduct - report abuse