Libraries like Jackson make it entirely painless.
I would assume JSON parsing is a solved problem in any typed language.
record Thing(String name, int size, LocalDate when) {}
The only way I could see this being easier is to forgo type safety completely.These things are just better when you aren't in a nominatively typed language with some pretty crusty assumptions.
That's not a gain in any way.
Since I/O is usually untyped, you need to cram it into a typed schema somewhere. In strictly typed languages, that must occur upon ingestion. The author is saying you can delay it by having a layer on top of the I/O transform the data in untyped fashion before being typed later on.
I have seen large applications (think hundreds of millions of daily users) break because of such oopses.
That's funny, because last time I had to write json-related code in Python, I really missed Rust's serde, which makes deserialization + validation much easier to write in Rust than in Python.
YMMV, of course.
By contrast, duck-typing means that the intricacies of which exact type you are deserializing into is a lot less important in python.
Am I missing something?
How do you explain the popularity of type hinting in Python then? Type hinting arose _because_ duck typing is horrible for large systems.
I’ve come to Python 20 years ago after a short stint with PHP and I don’t really care if the incoming stuff I have to handle is a list or a tuple (let’s say) as long as it quacks and walks like the proverbial duck.
More generally, you could say Python the original language is the victim of its own success (the same goes for JavaScript in relation to TypeSctipt).
The only not so easy decision is: is it better to store as Unix epoch or as ISO string. That is a tradeoff between compactness and easy searching of date/time ranges.