5 ms·
We've spent like 10 years trying to fill in gaps left when we all decided to hate XML. JSON is great as a lightweight DIF between trusted partners. If you care
by tootie 8y ago
We've spent like 10 years trying to fill in gaps left when we all decided to hate XML. JSON is great as a lightweight DIF between trusted partners. If you care about maintenance and safety, XML with XSD is rock solid.
- JustSomeNobody 8y agoXML isn't bad, but everyone went crazy and decided to use it for everything which didn't work out well. Then the backlash happened.
- TillE 8y agoXML is in that odd middle-ground where it's usually human-readable, but also a huge pain in the ass to write. It's great at what it was intended for, as a data interchange format. For a general-purpose human-writable structured data format, I guess the ugly nonstandard hack that is "JSON with comments" is probably good. It's certainly faster to parse than YAML.
- dagw 8y agoI've managed to teach non-programmers to successfully edit YAML files without too much trouble, but most non-programmers have a really hard time consistently producing valid JSON by hand. As much as there is a lot to not like about YAML, it is the easiest one for humans to consistently write in my experience.
- jodrellblank 8y agoBut why should they have to do it by hand? We don't judge Excel and Librecalc by how easy it is to open their files and produce valid spreadsheets without good tooling. If they're working with structured data, why can't they use tools/editors which work with the structure, reveal it, and enforce it?
- tannhaeuser 8y agoXML wasn't intended as data interchange format, but for replacing SGML as serialization and markup meta-language on the Web (eg. for XHTML, SVG, MathML). It can't be said often enough that markup languages are for authoring and delivering semistructured text data, not for general-purpose data serialization. As in, editing plain text files and have your text treated as content unless marked up with markup and annotated with metadata attributes. Though this is much more pronounced in SGML which also contains the features for authoring (as opposed to delivery) omitted from XML such as tag omission/inference, custom Wiki syntaxes, and other short forms.
- Mikhail_Edoshin 8y agoWell, what is the purpose of markup languages? Isn't the sole purpose of markup is to be able to process the marked-up content with a computer? Why would you add markup to your favorite verse if it wasn't to somehow feed it to machine for some purpose (analyze, typeset, etc.)? So when we have text with markup the text part is meant to be there for humans and the markup part is solely for computers. Now let's remove all text; now there's no content for humans at all, only for computers. How is this different from general-purpose data serialization? (Some of the samples you give, like SVG, may not have any text content at all; it's basically a drawing language.) Given that XML ecosystem has quite a few tools (e.g. several type description languages or a declarative data transformation language just to name a few) it's a very good general-purpose data serialization format.
- slavik81 8y ago> It's great at what it was intended for, as a data interchange format. XML's incredible verbosity is a problem for computers too. I've spent time performance-tuning message parsing code that had no good reason to be slow except that our use of XML bloated the data and decoding time by an order of magnitude or more compared to a binary protocol with a schema.
- zaphar 8y agoIn my experience if you are using XML as a data interchange format and it's slow it's probably because you are using a DOM parser instead of a SAX parser. DOM parsers build a tree that is best used describing a marked up document and much less useful for describing a data structure you might want to serialize or deserialize. I've gotten incredible speedups just by switching to SAX parsing in those cases.
- jameslk 8y agoMy biggest complaint with JSON is the lack of support for comments. For that reason, it's hard to take it seriously for human-maintained configurations.
- doktkrknr 8y agoI got hit by lack of comment support in go-yaml recently. https://github.com/go-yaml/yaml/issues/132 https://github.com/go-yaml/yaml/issues/132
- klodolph 8y agoComments and trailing commas. If those two features were added, I would use JSON for configuring everything. Naked keys would be a distant third. My conclusion is to use TOML or the protocol buffer text format. I've been slowly ripping out YAML support and converting configurations to TOML.
- furgooswft13 8y agoNot just trailing commas, but the need for commas at all when there is a newline right next to it has been a source of many stupid issues for me when less knowledgeable/experienced people edit json based conf files. Then there is floats without a leading zero. Missing colon after the key. And yea, naked keys. The need to wrap the entire file in { } or [ ] is just icing. Honestly I feel the most bare simple conf format of [first-word] [rest-of-line] is enough for many programs that end up using but never taking advantage of more powerful formats.
- nawgszy 8y agoWhat is a DIF?
- ChrisSD 8y agoTo be quite honest I dislike using XML for human editable configuration files. Variations on Microsoft's .ini files (such as TOML) seem to work best for that, IMHO.
- TimJYoung 8y agoWe use .ini files for all of our settings in our products, and they work great most of the time. The only weirdness creeps in when you try to store things with embedded CRLFs and need to escape/unescape them (not a big deal), and storing lists of things is a little difficult. JSON is great in terms of flexibility, but .INI files are really easy to read because everything is on the left side of the screen/window at all times.
- nathancahill 8y agoSafety? Sounds like rosy retrospection to me. We're still dealing with XML vulnerabilities.
- jmisavage 8y agoEspecially when technologies like E4X came out to make writing and reading XML in JS so much easier. Although I don't miss SOAP at all.
- tptacek 8y agoXML has many of the same security problems that YAML does, and even some additional ones.
- commandlinefan 8y agoI don't know, XML is awfully verbose and the schemas are even more verbose. I've lost track of how many "XML" configuration files that looked like this: <parameter> <name>ApplicationName</name> <value>WhizBang</value> </parameter> ... So that they could pass schema validation and still have some hope of extensibility.
- organsnyder 8y agoWhy not just <parameter name="ApplicationName" value="WhizBang"/> ?
- rocmcd 8y agoThat's the age-old question, isn't it? Your option is better, but XML is very (maybe too) flexible and is bound to be made a mess of.
- organsnyder 8y agoI've seen some pretty messed up schemas in JSON and YAML, too.
- commandlinefan 8y agoThat's still worse than <ApplicationName>WhizBang</ApplicationName>. Or ApplicationName=WhizBang
- hyperman1 8y agoA few weeks ago, I had about 100 config files (tomcat context.xml) which all needed fixes for common misconfigurations - if they had the misconfigurations in the first place The kind of problem that is just a little bit too hard for search and replace. It was really easy with xslt. The result had all comments preserved. I choose to reformat the files, but keeping whitespace was an option too. Now tell me if you can do that with json,yaml,toml. Most parses simply forget about the comments to begin with. In the same way, if we receive a data transfer in XML and there is a schema, simple validation catches a lot of problems quickly. You'd be surprised how many times a company gives you a schema and then sends you xml which doesn't validate. In JSON, you have to write a program to get even basic validation. Don't get me wrong: XML has problems, some inherited from html/sgml (entities!), and even more after serious abuse by consultants, archicture astronauts and enterprise vendors (SOAP! namespace overuse! 10 XML parsers in 1 app!). But it was also miles better than what came before and I feel the XML hatred pendulum has swung too far. Today, JSON is in vogue, and I've seen enough IT to not swim against the tide. It is a reasonable solution for problems caused by XML abuse. Besides, there is value in going with the majority,even if it only fixes 80% of your problem. But I can only weep for the miserable date, numeric and comment support, and their endless stream of incompatible workarounds. For your parameter example: You can't both strictly validate and have full freedom at the same time. Something has to give a bit. Some less horrible alternatives I've seen: <parameter name="X" value="Y"/> <subsystem name1="value1" name2=value2 ... /> , add newline for each attribute <name>value</name>
- strictnein 8y agoSafety? The OWASP Top 10 doesn't feature a JSON security issue. https://www.owasp.org/index.php/Top_10-2017_A4-XML_External_Entities_(XXE) https://www.owasp.org/index.php/Top_10-2017_A4-XML_External_...
- tootie 8y agoDTD and SOAP are both awful.
- outworlder 8y agoWell, if you go deeper down the rabbit hole, XML was a complete and utter waste of time. This problem was solved in the 60's with S-Expressions.
- ivan4th 8y agoYeah... I'm a diehard Common Lisp user, and when I saw YAML+go-template used for Kubernetes Helm templates, with some extra hacks to take care of indentation shifts... I felt almost physical pain.
- mncharity 8y ago> This problem was solved in the 60's with S-Expressions. Not so much. Sexps don't provide a place hang "extra" information. It's been a pain point. While some lisps allowed decorating runtime things (eg objects with attributes, and symbols with property lists), their printed/readable representations were implementation dependent. There's also a widespread misconception that Scheme is easy to parse. Numbers and all. It's actually very hard to get right. Real scheme parsers are quite large and hairy. > XML was a complete and utter waste of time. While XML was ghastly, there was an unmet need. There still is.
- suresk 8y agoI get a lot of flak for this, but there are definitely times I miss XML for certain things and find it way easier to work with than JSON or YAML. I definitely understand some of the backlash against XML that happened a decade or so ago and definitely don't want to return to the days of half of a Java application being XML code. I think JSON is more efficient to write, but XML often ends up being more efficient to read due to comments and the fact that XML tags often give you better context. I think most programmers (myself included) tend to heavily optimize towards writability when we should think about readability a little more. An example of this is ElasticSearch, where your queries are in JSON and often end up tons of levels deep - it is super easy to get lost in a sea of closing brackets, whereas XML would let you add comments in and the fact that closing tags have names in them would give you better context about what you were doing.