3 ms·
> You still know that the "customer_name" argument to it will be a string and the "age" will be an integer, no? I've seen integers sent as strings and others a
by pmontra 8y ago
> You still know that the "customer_name" argument to it will be a string and the "age" will be an integer, no?
I've seen integers sent as strings and others as integers in the same JSON. Datetimes stored as strings in three different formats by the same application in the same column of the same table, etc. The real world is really messy. Writing a new program is definitely quicker with a language like Ruby or Python for me (especially Ruby.) Working with Java is like walking with a cast on a leg.
But you know, every project and every developer is different, that's why we are using so many different tools. The OP accounts for that in the "There are many arguments in favor of static-typing" paragraph.
- coldtea 8y ago>I've seen integers sent as strings and others as integers in the same JSON. You still need to know what they are in each case, regardless of dynamic vs static typing (it's a matter of whether the language has weak vs strong typing or overly accommodating coercion). If you get an integer value as string for example, Python won't let you add it to another integer you got as integer. So you'll need to know what they are to treat them accordingly in your processing even in a dynamic language. In such case, you can also read them as a variant type on a static language, that's eg. one of the 7 allowed types in JSON (you don't know whether a JSON primitive might be int or string, but you know it wont be suddenly a Date type or a Foobar instance).
- majewsky 8y ago> I've seen integers sent as strings and others as integers in the same JSON. So what? Just use a veryFlexibleUint64: https://github.com/sapcc/limes/blob/d51ecdbb763318da146b9f3246ffc993c2632947/pkg/plugins/client_ironic.go#L127 https://github.com/sapcc/limes/blob/d51ecdbb763318da146b9f32... ;)