The type system is a programmer's best friendI am tired of primitive obsession and the excessive use of primitive types to model a domain.
A string value is not a great type to convey a user's email address or their country of origin. These values deserve much richer and dedicated types. I want a data type called EmailAddress which cannot be null. I want a single point of entry to create a new object of that type. It should get validated and normalised before returning a new value. I want that data type to have helpful methods such as .Domain() or .NonAliasValue() which would return gmail.com and foo@gmail.com respectively for an input of foo+bar@gmail.com. Such useful functionality should be embedded into those types. It provides safety, helps to prevent bugs and it immensely increases maintainability.
https://dusted.codes/the-type-system-is-a-programmers-best-friendconipto 837 points 12 hours ago
Compile time errors are better than runtime errors.
Change my mind.
grelphy 47 points 3 hours ago
Earlier failures are always preferable. Compile time is better than runtime. Initialization is better than mid-execution. Barfing on ingesting bad data is better than barfing on retrieving it from storage. Et cetera.
The number of people who will agree with "fail early" as a principle and then evangelize unityped languages is baffling to me.
https://old.reddit.com/r/programming/comments/yj5mbd/the_type_system_is_a_programmers_best_friend