3 ms·
You can do some actually useful stuff with a real type system, instead of replicating Perl's stupidity. For example, you can convert the input into a safe repr
by marcosdumay 6y ago
You can do some actually useful stuff with a real type system, instead of replicating Perl's stupidity.
For example, you can convert the input into a safe representation, suitable for the exact place you'll be using the string, instead of "validating" it.
- masklinn 6y agoExactly. What you need is not a “tainted” type and assume everything that’s not it is safe. That’s not the case. Html-escaping a string does not make it safe for SQL or whatever. What you need is a safe type for each use case, and ways to convert values to that (or mark them as that depending on your TS).
- staticassertion 6y agoThis is what I was referring to at the end of my post: > Few work directly on strings. But they do it naturally, without enforcement - so like, a function might take a 'str', but the 'str' passed in was parsed into a wrapping structure already. ie: Most programs in typed languages already do what you're saying - they parse the data directly into a structure, and therefor they validate some aspects of it naturally, so even when you do see a 'str' in typed code it's very often already gone through some sort of parsing phase.
- marcosdumay 6y agoHum... Your sibling has a nice explanation of what I was trying to say. You don't sanitize user input when parsing, you do it on usage. "Robert'; drop table users--" is a perfectly fine name and you shouldn't mangle it on you data fields.
- staticassertion 6y agoWe're saying the same thing.