Re:What I Want from a Type System (2016)
by z3t4 on Monday July 01, 2019 @09:04AM
(#20324824)
If you find naming things difficult just append the type to the variable name, like strName, strCityName, nrAge, arrUserList, and try to make the types redundant. Then stop using the type annotations when you feel they are unnecessary: strName:string -> strName -> name
This of course only works in high level dynamic languages where you wont have 25 ways to represent a number, or 32 ways to make a string (different encodings). In a typed systems level language the compiler should be able to optimize and figure out the best type to use though.
[ Parent
| on HN ]
But why would you use the type "string" in the first place, instead of declaring a type "name"?
To take it one step further, why does it need to have a type? Why can't the compiler just figure it out?