5 ms·
This article is pretty garbage. compares almost nothing about xml and instead compares the tooling around xml giving no thought to the tooling around json. ins
by jtmarmon 11y ago
This article is pretty garbage. compares almost nothing about xml and instead compares the tooling around xml giving no thought to the tooling around json.
instead, let me give you my unsolicited opinion:
if you need to represent both the structure of your data and characteristics within that structure, xml is great because attributes are a really good way to do that. there's a reason most UIs are represented as XML.
if your data is just - well, data - use json. or better yet use edn
- calanya 11y agoIt's funny to say json and edn represent data, because they are both strictly UTF8 encoded - raw bytes have to be encoded somehow (with neither standard specifying a prefer erred method) to be represented. Why is this important? Sometimes we want to embed a binary formatted piece of data (e.g. an image) as part of our data.
- frou_dh 11y agoIsn't that the point of the 'hashtags' in edn? If a #png arrives then your program is going to throw an exception unless you've registered a handler that reports success in decoding it? In effect it doesn't matter than the encoding is arbitrary edn (e.g. a 150KB png could be a solitary bigint literal) because the tags prevent false-positive decodes and keep things "strongly typed".
- deleted 11y ago[deleted]
- TeMPOraL 11y agoExcept what if "characteristics within that structure" also have structure? Attributes are an ugly, crippled special case of a tree node; they make some sense in a markup language, but for serializing data, I see zero point in using them. As for why UIs are represented in XML? It seems like a simple case of people getting used to it before JSON was popular. XML is a default choice for Java and for C#. It also looks vaguely familiar to HTML.
- jtmarmon 11y agoAgreed, they're not convenient for arbitrary attributes. I think where they shine are using a well defined preset of attributes to define structure. Regarding the legacy thing, I think it's both. If you look at a lot of new tooling coming out that has to store UI state, people are still using XML
- ro_sharp 11y agoIf you control consumers and producers, and your data is just data, please just use a safe, common binary protocol (protobuf etc).