3 ms·
> Your custom class with getters/setters is nothing more than an ad-hoc dictionary. I'd say that a dictionary is an ad-hoc, typeless instance. > I don't want
by zeveb 10y ago
> Your custom class with getters/setters is nothing more than an ad-hoc dictionary.
I'd say that a dictionary is an ad-hoc, typeless instance.
> I don't want a custom type where I have to write boilerplate around for every single operation
That's why I use a language which lets me abstract away boilerplate:-)
> S-exprs by themselves are just data, they're the very same as JSON (not versioned, not extensible). YAML supports tags making it easy to plug your custom types directly into its reader.
I prefer (no surprise!) the Lisp reader, which does offer ways to plug your own types directly in with read-macros.
- jeremiep 10y ago> I'd say that a dictionary is an ad-hoc, typeless instance. The dictionary will preserve the entirety of the data, that's already better than any custom type can ever dream to do. You're not going to want to upgrade your codebase every time a 3rd party adds fields to their documents. Trying to make data "safe" by giving it strict types is only going to result in the destruction of data and no actual gains in safety. > I prefer (no surprise!) the Lisp reader The Lisp reader is not a data format nor is it available outside Lisp. That's no good on the wire unless you live in a sandbox and never talk to the real world. You're going to receive data with fields/types your program do not understand (the endpoint could've pushed a new version without your knowledge) and there your ad-hoc types will become pain points. Imagine if we tried to make HTTP "safe" by giving types to everything. The second a proxy sees a header it doesn't understand the request would fail. We'd have absolutely no internet. Distributed systems depend on the fact that you're able to handle unknown data and types.