
Ask HN: Why did XML failed to be the standard for data format? - stevefan1999
I mean, most of anything that somewhat touches XML had failed miserably [1]. SOAP, XMPP, and to a certain extent, XAML on WPF&#x2F;Xamarin is also a failure; it seems like to me that JSON is the lingua franca of the data format world despite that JSON was lacking in some useful stuff (e.g. a schema system), what makes it that XML has met its disappearence.<p>[1]: Yes, I know HTML is also a derivative in the  family of XML&#x2F;SGML, yet don&#x27;t most of you frontend devs think that HTML sucks too?
======
rs23296008n1
Every xml file I've ever encountered was broken in some way or malformed
compared to its schema. Manual adjustment was nearly always required in some
way. (Yet they had schemas and full descriptions) JSON files come in all sizes
and complexity but typically work better. Much easier to read/write using
automated tools. XML is far too complex to read with simple parsers in a
performant way especially when compared to JSON.

For data transfer now I'd actually prefer csv over xml due to the simple fact
I can at least sanitise it. _That_ is how low my opinion has gotten over years
of data migration projects. In my new work I primarily work on JSON / csv /
tsv and would not even consider xml. XML schemas have the idea of keeping data
clean etc as well as guiding parsers etc but the added functionality comes at
a price in performance and parsing complexity. I did find the xml
transformation abilities useful however.

My personal opinions aside, friends of mine using java still swear by xml so
if you're from that crowd your opinion might differ. I'm guessing the java
infrastructure is more forgiving but its been too long for me to assume more
than that. They obviously find utility in it: terabytes of xml is not trivial
by any stretch of the imagination.

~~~
datalist
I beg to differ.

In its raw form XML is not much different from JSON. It is more verbose (e.g.
start and end delimiters versus a name tag in JSON) but overall very similar,
if not identical in terms of features. Schemas are a different topic.

Reading and writing with automated tools very much depends on these tools and
not so much on the syntax itself.

JSON is slightly slimmer and less verbose but does not really offer any
fundamental advantages. Both syntaxes are very similar. The reason why JSON is
more popular nowadays can be most likely found its relatively close ties to
JavaScript and JavaScript's success in web development.

~~~
silicaroach
JSON is not 'slightly' slimmer and less verbose, it is considerably so and
it's format very_obviously_ conforms to an object structure and so a JSON file
is actually legible. xml was just a port of html with all the verbosity. JSON
is a cleaner expression of what xml was trying to represent, Occam's razor and
_that's_ why JSON is more popular

~~~
datalist
I believe you are wrong, but let us simply agree to disagree ;)

~~~
datalist
I believe I was a bit too quick in just dismissing your response, my
apologies, so let me please elaborate on why I believe you are wrong

\- "Obviously conforms"? XML does too. Both are hierarchical document formats.
Their syntax is different, thats about it.

\- "Considerably slimmer"? That is arguable, I'd say "slightly". But yes, JSON
is somewhat leaner. So what, that doesnt make it intrinsically superior.

\- "Legibility"? That mostly depends on the formatting. Especially in today's
world and its minifiers essentially nothing is legible any more. JSON, being
less verbose, might have a fraction of an advantage here, but again thats
about it.

Examples? Sure. Would you argue the following JSON document is legible?

    
    
      [{"_id":"5e120086aa2b07d5af7ddda3","index":0,"guid":"ae823405-6305-4c29-a8d3-429423e0ff7c","isActive":false,"balance":"$2,616.37","picture":"http://placehold.it/32x32","age":36,"eyeColor":"green","name":"Lyons Pollard","gender":"male","company":"TECHMANIA","email":"lyonspollard@techmania.com","phone":"+1 (870) 441-2429","address":"722 Truxton Street, Osmond, Indiana, 1802","registered":"2018-03-14T10:56:23 -01:00","latitude":43.427473,"longitude":-78.16956,"tags":["id","voluptate","velit","sit","duis","velit","proident"],"friends":[{"id":0,"name":"Elba Fernandez"},{"id":1,"name":"Rosalinda Morrow"},{"id":2,"name":"Hannah Leblanc"}],"favoriteFruit":"apple"}]
    

Didnt think so. In comparison its XML equivalent is pretty legible

    
    
      <?xml version="1.0" encoding="UTF-8"?>
      <root>
        <element>
          <_id>5e120086aa2b07d5af7ddda3</_id>
          <address>722 Truxton Street, Osmond, Indiana, 1802</address>
          <age>36</age>
          <balance>$2,616.37</balance>
          <company>TECHMANIA</company>
          <email>lyonspollard@techmania.com</email>
          <eyeColor>green</eyeColor>
          <favoriteFruit>apple</favoriteFruit>
      
          <friends>
            <friend>
              <id>0</id>
              <name>Elba Fernandez</name>
            </friend>
            <friend>
              <id>1</id>
              <name>Rosalinda Morrow</name>
            </friend>
            <friend>
              <id>2</id>
              <name>Hannah Leblanc</name>
            </friend>
          </friends>
      
          <gender>male</gender>
          <guid>ae823405-6305-4c29-a8d3-429423e0ff7c</guid>
          <index>0</index>
          <isActive>false</isActive>
          <latitude>43.42747</latitude>
          <longitude>-78.16956</longitude>
          <name>Lyons Pollard</name>
          <phone>+1 (870) 441-2429</phone>
          <picture>http://placehold.it/32x32</picture>
          <registered>2018-03-14T10:56:23 -01:00</registered>
      
          <tags>
            <tag>id</tag>
            <tag>voluptate</tag>
            <tag>velit</tag>
            <tag>sit</tag>
            <tag>duis</tag>
            <tag>velit</tag>
            <tag>proident</tag>
          </tags>
      
        </element>
      </root>
    

Yes, more verbose - which I already addressed - but nonetheless self-
explanatory. One advantage of JSON? Additionally to strings its core syntax
defines three additional value types, whereas in XML everything is a string.

XML and JSON are so similar they could be considered siblings. JSON's
popularity does not stem from being "a cleaner expression of what xml was
trying to represent" because everybody using it made a careful evaluation and
decided after long deliberation that JSON is "Occam's razor", but simply
because it is the default choice in JavaScript and comes with native support,
whereas XML support is pretty shaky in Vanilla JavaScript.

That is why - to adopt the same confident attitude ;)

Would I slightly favour JSON over XML these days? Yes, probably slightly, but
certainly not because it was better or offered things XML didnt.

------
mattbillenstein
xml is too complicated and too easy to get wrong - try consuming rss feeds and
the amount of malformed xml you'll find is astounding - people basically
template xml, so you'll get just bad syntax and text encoding problems.

json avoids these pitfalls and people mostly just use a lib to generate it
from native data structures, so it's almost always well-formed.

~~~
datalist
If you have a malformed JSON, that will break too. So the issue is not with
the syntax but - if - with the tools, respectively as often with the - pardon
for being blunt - people's incompetence.

