When you think about type safety, what do you think about? Alex asked this question on social media, got some interesting answers, and ended up defining a few principles for a style of programming with “hidden types” as follows:
A) I don’t define types for method and function parameters, or class members
B) I validate a lot at the entry to the system
C) I define my own objects and use them with duck typing (aka if it has the method or data member with the correct name then it’s the correct type)
D) I name everything precisely
The surprising thing about this style is that it didn’t get us in trouble. So are types actually important to prevent programming mistakes? Or are they just a preference?
Here’s the mastodon thread: https://mastodon.social/@alexboly/110094459845150970.