▲ | Spivak 14 hours ago | ||||||||||||||||
I mean they clearly don't have to, Python has the same problem of being able to pass anything—you don't see this kind of incredibly defensive programming. But Python set a culture of being for "consenting adults" where it's expected that callers will read the docs and ensure preconditions are satisfied, and if they don't whatever happens, happens. It leads to less code, and more generalizable code. Maybe the caller does know what they're doing, who am I to say they can't. | |||||||||||||||||
▲ | pcwelder 14 hours ago | parent [-] | ||||||||||||||||
>if they don't whatever happens, happens What happens is you get an error. So you immediately know something is wrong. Javascript goes the extra mile to avoid throwing errors. So you've 3>"2" succeeding in Javascript but it's an exception in python. This behavior leads to hard to catch bugs in the former. Standard operators and methods have runtime type checks in python and that's what examples in the article are replicating. | |||||||||||||||||
|