3 ms·
I don't really buy this argument about readability because the sort of information stored in types very quickly becomes pretty meaningless for humans. I remembe
by Barrin92 6y ago
I don't really buy this argument about readability because the sort of information stored in types very quickly becomes pretty meaningless for humans. I remember working on a Haskell codebase and getting into an argument about this with a developer who was very much in the typed language camp.
Then I saw a function that had like 8 parameters, some were just String, or Int, some where synonyms, and I asked him what it does based on the type signature. He didn't know. I didn't know either. Int -> Int -> Foo -> String -> Foo very quickly starts to mean nothing.
Types don't enhance the meaning of the code. if you want to understand your code better, what you're looking for is better names, not better types. As far as understanding code is concerned, in the best case types have the exact function as names, in the worst case they entice people to write 'int x' rather than giving something a proper name.
- j-krieger 6y agoThe magic is in the combination of types and proper names. What use is a variable that‘s nicely named when you don‘t know what it holds?
- deleted 6y ago[deleted]
- resonantjacket5 6y agoIf you don't have types you still might not know what to pass in. I mean if it says function( id, filePath, newStudent) is id a number or a string. Or say filePath perhaps you have a defined class for that instead of passing in a string. Sure you could write it as function( idNumber, filePathString, newStudentClass) but you're just reimplemting types as a naming scheme that isn't able to be checked compile time.
- tome 6y agoHuh? Just because there was once a function whose argument types didn't help you understand it doesn't imply that types aren't an aid to readability in general!