3 ms·
> static typing does not prevent all type errors. Everything what arrives on the wire can blow your program up. How?
by yawaramin 8y ago
> static typing does not prevent all type errors. Everything what arrives on the wire can blow your program up.
How?
- doubleunplussed 8y agoBecause it's just bytes, which may or may not deserialise to the type you expected.
- yawaramin 8y agoThat shouldn't blow up my program. If it doesn't deserialize to my type I handle that as a normal branch in my code.
- doubleunplussed 8y agoSure, but now you're enforcing types manually instead of with a type system. What have you gained over not having a type system? In this case, nothing.
- yawaramin 8y agoIt's still enforced by the type system. The type-safe deserialization libraries nowadays use 'result' types to indicate success or failure. The compiler forces you to handle both.
- rad_gruchalski 8y agoI’m guilty of HN generalisation. It depends on the language implementation of type system. In Java - any null can blow your program out. Type system is not going to help. Golang, with interfaces and nil pointers can blow you out of the water. So whenever something was expected to arrive from the wire, it does not parse correctly, depending on the parsing method, once you have that null, all bets are off. Type system gave up. It all depends. Another example is Java interfaces. Merely checking for an interface type does not prevent errors down the line. It does limit the amount of errors.