Re:The Next Step for Generics
by amelius on Tuesday June 16, 2020 @06:56PM
(#23545341)
Ideally, you'd have a language that allowed you to do both. Generics/type safety when you want them (e.g. for stuff that is hard to maintain), and total freedom otherwise.
[ Parent
| on HN ]
Python with type annotations is the closest I've used to that, and I hate it. It beats no type annotations, but only barely.
As soon as I need to use someone else's code, all bets are off. Half the reason I want types is because it makes my life easier when I'm trying to use something written by someone else -- instead I find myself needing to experiment with a debugger to figure out what functions are actually doing.
Plenty of languages allow you to do this, either by opting into type checking only when you add type annotations, or by using "any" / "dynamic" or unchecked typecasts as an escape hatch when you don't feel like going through the trouble of how to make the typechecker happy.
C# with liberal use of "dynamic" would be pretty close to that.