5 ms·
Now in 2015 we have XML prejudice and aversion where people trash XML as the worse possible format. As with many things it has its strength and weaknesses a cou
by agentgt 11y ago
Now in 2015 we have XML prejudice and aversion where people trash XML as the worse possible format. As with many things it has its strength and weaknesses a couple of them being that a parser exists for almost all programming languages and the syntax of XML is probably the most widely understood (given so many people know HTML). And while XML is complicated there are far more complicated formats (YAML).
What we have today is format creation fever. Particularly in configuration languages. Hucon, TOML, YAML, JSON, sort of JSON formats (HJSON or whatever it is).
- zdw 11y agoRequisite XKCD link: https://xkcd.com/927/ https://xkcd.com/927/ The problem with XML is that there are a lot of different programming models (streaming, pull, DOM), many schema and validation formats (DTD, XSD, RELAX NG), to the point that most people didn't care and just manually generated some monstrosity surrounded <>'s using printf. Personally, the way to get value out of using XML today is to find or make a schema in the most restrictive and expressive format possible that's supported by your development environment (RELAX NG or Schematron are the prime contenders), then use it as a safety belt every time you read or write data. The schema helps handle all the nastiness of parsing, which is the real enemy: https://www.usenix.org/system/files/login/articles/login_aug15_02_bratus.pdf https://www.usenix.org/system/files/login/articles/login_aug...
- agentgt 11y agoI agree but XML the language with out namespaces or schemas is still useful. Schema like technology are surprisingly hard to implement and very similar to writing a type checker. Most human readable formats do not support any sort of validation and just now we are starting to see the newer formats try to come up with schema specifications (http://json-schema.org/ http://json-schema.org/). I think the problem with XML has little to do with the language but the organizing ivory tower organizations that got carried away with extending it... but at least those extensions/enhancement were extensions and not modifications of the language itself (ie new versions). An anecdotal observation is newer specifications for languages seem to follow a more open and transparent ala OSS philosophy (ie spec is on github).
- kyllo 11y ago...when all we really needed all along was S-expressions.
- zeveb 11y agoIt really is appalling how many man-millennia have been spent reimplementing an already-realised ideal. Imagine how much better the world would be if we had settled on Lisp or Smalltalk plus s-expressions back in the early 90s!
- kabdib 11y agoWish I could upvote this more than just once. OTOH you kind of need hashes/maps in the real world (sexprs can provide this by syntax, but not necessarily by agreed-upon function). And Unicode. And standard representations for the base datatypes. But aside from that there's no reason to enter the Sea of Arbitrary Anglebrackets.
- kyllo 11y agoOTOH you kind of need hashes/maps in the real world (sexprs can provide this by syntax, but not necessarily by agreed-upon function). And Unicode. And standard representations for the base datatypes. I believe Clojure's EDN format offers all of the above https://github.com/edn-format/edn https://github.com/edn-format/edn
- zeveb 11y ago
- jhpriestley 11y agoI don't think the syntax of XML is widely understood. How many people really know the syntax of DTDs, processing instructions, entity references, namespaces, CDATA sections, and so on? Tags-and-attributes are widely understood, and a format which was just tags-and-attributes would be a reasonably good format. XML is far too complex for its purpose.
- agentgt 11y agoI'm almost positive we have worked together (your handle stuck out... percussion?)... I agree the extension/validation parts of XML are not well understood (DTD, entity references, namespaces) but in general rarely used or needed. Most uses of XML in the past and today use just mainly tags and attributes. XML purpose was for an extensible document format not a general purpose programming language, DSL and/or a serialization format. For its original purpose it isn't a terrible format. Document formats require special handling of space and comments and repeated nodes (see my other comments). Even S-Expressions ignore spaces in general so are probably not a good format for documents.
- jhpriestley 11y agoAh, so you're that "agent". You're right, we worked at Percussion together in 2009 :)
- jgalt212 11y agoPlease don't trash YAML. If you stick to "the good parts", YAML is an almost perfect human/machine readable and editable text format. For example, we store almost all our parameterized test cases in YAML because we can then use these files as inputs to test runners in JS, Python, Go, etc.
- agentgt 11y agoI didn't mean for that to be an interpretation of trashing YAML. The YAML format is more complex to parse and there are less parsers available. It is an easier to read format for sure but that comes at a cost. There are lots of good things about YAML.
- weland 11y agoTo be fair, if you stick to the good parts, any language is good. It's the good parts : bad parts proportion that tends to ruin things.
- legulere 11y agoIt's just because XML is a bad choice. It's a standard for creating markup languages, but use in HTML failed because it's more verbose and doesn't cope at all with user errors. For data serialisation it's just insane. The only reason to use XML to serialize your non markup data is that it's a web technology and you have parsers everywhere. Mapping data back and forward between your data structures and the XML representation is a huge pain in the ass, as there's no natural mapping. For some formats like SVG you basically have to keep data as a DOM in your program. > And while XML is complicated there are far more complicated formats (YAML). While the Syntax of YAML certainly is more complicated, totally I would say that it's less complicated without all the XPath, Namespaces etc. you additionally need. YAML maps fairly direct to data structures of programs and the complexity is there to get human readability and edit ability. Something XML doesn't have when used for general data. > TOML Is basically just a specification of the largely unspecified INI format, which is older than XML. This is just a format for human editable configuration files, for which we have experience that XML really really sucks. > JSON Very simple data format that maps directly to data structures of all common programming languages. The fact that JSON beat XML where XML is at home, in the web shows pretty clearly that JSON is the better format for data serialisation. TL;DR: Use the correct format for the use case. XML is for markup, not serialisation. JSON is for serialisation, YAML is a better readable JSON e.g. if you mainly use the data for debugging, INI(/toml) is for configuration files.
- agentgt 11y agoWhile I think we are on the same page (I did say XML has strength and weaknesses) I think XML is undervalued for a configuration language particularly if the configuration language is to be modified by another application or script. The reason a markup language like XML is actually sort of useful for a configuration is that spacing and comments can be preserved on modification. That is if I modify the XML manually and then modify it with a script (assuming the script is written correctly) I can preserve my formatting and my comments. As far as I understand such is not the case with many formats (I suppose YAML would be the exception albeit I'm not sure if it preserves white space other than the required whitespace). I have actually had this use come up. I had 20 or so Maven POM files that I had to modify/refactor. It was fairly easy to do because it was XML all while preserving the formatting and comments. With the exception of massively complex configuration (aka Ansible) I really don't think most users (particularly non-techy) care that XML is slightly more verbose than YAML. Particularly since configuration is not modified that often and again its like HTML (although HTML is a failure technology wise it is ubiquitous). As for serialization... XML is bad... I can't come up with any devils advocation for that.
- dragonwriter 11y ago> the syntax of XML is probably the most widely understood (given so many people know HTML). HTML and XML syntax is similar (because both are descendants of SGML, and XML was informed by -- but also in some respects a reaction against elements of -- HTML), but not the same; they are more members of the same syntax family, in the same way that large numbers of programming languages are members of a syntax family descended from Algol.
- kpcyrd 11y agoxml is so complex and poorly understood, even big companies like google and facebook have failed to implement xml parsing securely, see xxe attacks. If you didn't know it's possible to configure the xml parser insecurely you might be affected, especially if you're using java. xml specifies how to load files from disk while parsing and validation can trigger GET requests to firewalled systems. All I want to do is parsing a simple data structure.