3 ms·
Oh, come on, static typing does not prevent all type errors. Everything what arrives on the wire can blow your program up. > Also if you control the client and
by rad_gruchalski 8y ago
Oh, come on, static typing does not prevent all type errors. Everything what arrives on the wire can blow your program up.
> Also if you control the client and the server, do not just blindly follow Postel's law and except crappy data.
But in real world, we do not livd in a bubble. Very often, we do not have the comfort of controlling the server and the client. We have keep edge cases in mind. Unexpected errors / cases happen.
- 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.