5 ms·
Your response is technically correct but completely useless. Of course if we all just programmed in the JSON data model everything would be simple. The author
by cratermoon 6y ago
Your response is technically correct but completely useless.
Of course if we all just programmed in the JSON data model everything would be simple. The author correctly points out the uselessness of that. He correctly identifies that the complexity lies in providing a useful JSON serialization library that is both compliant in input/output yet flexible enough to be configured to go from JSON object model to business model.
It's actually a complex problem, going from one type system to another. Want to know how complex? Just look at the compilers and interpreters that transform instructions for complex data types down to x86 (or M1, or RISC, or whatever) opcodes.
- whalesalad 6y agoYou can’t model the entire world. Well, you can, but you can’t. Take a look at schema.org to see where that rabbit hole will take you. So instead we use more primitive tools that allow us to model our domain without needing a tool that magically knows how to do it for us. My domain has unique nouns that differ from someone else’s. JSON offers building blocks of primitive types like integers and strings and can be used to build more sophisticated types like “timezone aware datetime”. We use ISO8601 for this. We can use that inside JSON. Now you and I can agree on what a date is. We could build this into the language itself - but many would argue the beauty of JSON is in the fact that it is very naive and can be used quite literally to model any scenario.
- cratermoon 6y ago> We use ISO8601 Ah yes, the old "stringly typed" data model. https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b923ca https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b... Application developers aren't trying to model the entire world, they are trying to model their domain, and I'm sorry, but primitive strings, numbers, lists, and maps are the building blocks of a domain model, but they are not sufficient. See for example https://fsharpforfunandprofit.com/ddd/ https://fsharpforfunandprofit.com/ddd/
- earthboundkid 6y agoThe F# post argues for marking OptionalStrings, but that’s bad design. There’s basically never a real distinction between string absent and string blank and if somehow your domain did have that distinction, you would need to record it as a bool or enum that clearly lays out “this is really blank and not just we don’t know it” or whatever.
- cratermoon 6y ago> There’s basically never a real distinction between string absent and string blank Oh, child. If someone came to me claiming that something not existing was the same as that thing existing but being empty, I might be inclined to refer them to a remedial course on logic.
- earthboundkid 6y agoGive a business example for a string specifically being modeled where blank is valid and distinct from null which isn’t better represented by a separate column for entry state.
- cratermoon 6y agoThere are more things in heaven and earth, Horatio, than are dreamt of in your philosophy
- earthboundkid 6y agoI too can quote something instead of addressing the topic of discussion. “Shimmy shimmy ya shimmy ya shimmy yay.”
- lmm 6y ago> There’s basically never a real distinction between string absent and string blank On the contrary, this comes up all the time; there are plenty of times when blank really is a valid value, and even if blank isn't a valid value, abusing it as a representation for "unknown" is bad for all the usual reasons in-band signalling is bad. > you would need to record it as a bool or enum that clearly lays out “this is really blank and not just we don’t know it” or whatever. An actual sum type is a million times better than using two awkwardly coupled fields. Type systems without sum types are a joke and there's no excuse for using them in the current millenium.