Type Safety as Error Prevention¶
Type safety means the language prevents certain categories of errors by construction - making illegal states unrepresentable rather than checking for them at runtime.
Tension Addressed¶
Safety vs. Flexibility
Recognizable As¶
Compiler rejecting invalid operations; inability to add a string to an integer without explicit conversion; option types preventing null pointer dereference by requiring explicit handling
Canonical Sources¶
Milner, "A Theory of Type Polymorphism in Programming" (1978); Wright & Felleisen, "A Syntactic Approach to Type Soundness" (1994)
Transfers To¶
API design (making invalid API calls impossible), schema design (constraining valid data shapes), state machines (illegal state transitions unrepresentable)
The profound insight is that types shift error prevention from runtime checking ("if this is invalid, throw error") to compile-time impossibility ("invalid states cannot be expressed"). This is "making illegal states unrepresentable" - a principle that applies to any domain where you can constrain the shape of valid inputs.