Why XML is all the rage now?

Started by
61 comments, last by TechnoGoth 10 years, 2 months ago
<obj type="someobject">
<argument name="arg0" value="value"/>
<argument name="arg1" value="value"/>
<subobjects>

<obj type="subobjecttype">
<argument name="arg0" value="value"/>
</obj>

<obj type="subobjecttype">
<argument name="arg0" value="anothervalue"/>
</obj>
</subobjects>
</obj>

In YAML:


someobject:
  arg0: value
  arg1: value
  subobjects:
    - arg0: value
    - arg0: anothervalue

In JSON:


{ "someobject" : { "arg0": "value", "arg1": "value", "subobjects": [ { "arg0": "value" }, { "arg1": "anothervalue" } ] } }
Advertisement
And just to reinforce my point, in INI:
[obj]
id=someobject
arg0=value
arg1=value

[obj]
parent=someobject
arg0=value

[obj]
parent=someobject
arg0=anothervalue

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

And just to reinforce my point, in INI:

Just when I thought "maybe I should do the INI too!" biggrin.png

In YAML:


someobject:
  arg0: value
  arg1: value
  subobjects:
    - arg0: value
    - arg0: anothervalue

In JSON:


{ "someobject" : { "arg0": "value", "arg1": "value", "subobjects": [ { "arg0": "value" }, { "arg1": "anothervalue" } ] } }

Hm, that doesn't seem right. Shouldn't it be:


arguments:
  arg0: value
  arg1: value
subobjects:
  - arguments:
      arg0: value
  - arguments:
      arg0: anothervalue

Points about JSON > XML aside...

As a game developer, the big deal to me is that it's a flexible standardized text format which means:

  • I don't have to create my own libraries to read, write, or navigate it.
  • At least for the purposes of developing and debugging tools that use, generate, or convert it, it's human readable.
  • It's diff-able and potentially merge-able, which to me makes it first-class revisionable.

^^ THIS!

It is a shame this is a Lounge post and we cannot upvote.

As a person who remembers the bad-old-days of the 90s and late 80's, I easily recall when most tools and technologies relied entirely on binary formats.

I don't care one bit if the language is XML, JSON, YAML, or Maya Ascii or Collada or anything else. That does not matter.

I absolutely care about factors like those above.

I absolutely care that as a developer I can understand and interpret the file without a binary-file parser. I can crack open a file, run a text search, and find the data I need. Even better, sometimes I can run find-and-replace on that file using simple tools.

I absolutely care that I can run diff against two versions of the file and see the difference. I can open a diff of two revisions with an artist sitting next to me, and we can both glance at the file and see that they moved a joint a little to the left.

I don't care about the exact format, but I strongly care that these human-readable, standardized, diff-able files are used. There was a time when storage space was expensive and everything needed to be encoded. We are past those days.

Add some newlines to that JSON example O_O

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.


In YAML:
someobject:
arg0: value
arg1: value
subobjects:
- arg0: value
- arg0: anothervalue
In JSON:
{ "someobject" : { "arg0": "value", "arg1": "value", "subobjects": [ { "arg0": "value" }, { "arg1": "anothervalue" } ] } }

Yeah, and in XML, the sane definition would be:

<someobject arg0="value" arg1="value">

<subobject arg0="value"/>

<subobject arg0="anothervalue"/>

</someobject>
Granted, there is some repetition of "subobject" and "someobject", but the bloat isn't really that much is it?


In YAML:
someobject:
arg0: value
arg1: value
subobjects:
- arg0: value
- arg0: anothervalue
In JSON:
{ "someobject" : { "arg0": "value", "arg1": "value", "subobjects": [ { "arg0": "value" }, { "arg1": "anothervalue" } ] } }

Yeah, and in XML, the sane definition would be:

<someobject arg0="value" arg1="value">

<subobject arg0="value"/>

<subobject arg0="anothervalue"/>

</someobject>
Granted, there is some repetition of "subobject" and "someobject", but the bloat isn't really that much is it?

this is why i like xml over yaml. json is interesting, but i'm sticking to xml personally. yea their's a bit of bloat, but imo xml's minor bloat is made up for in terms of readability. of course xml is obviously more easily abusable(as was pointed out above), but that shoudn't be a reason not to use something.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.


Granted, there is some repetition of "subobject" and "someobject", but the bloat isn't really that much is it?

Nah, and as a bonus it'll be also easier to parse for the program, so everybody wins (it's easier to hand-edit and the program is easier to maintain).

The problem is that XML tends to be abused in the worst ways possible x_x; It's like programmers see it's a tree so they need to turn everything into a deep as possible tree no matter what, just in case (some may argue it's for expandability). Ugh. Sadly, I wouldn't be surprised if that also reflects the complexity of the program themselves... (one reason why I always have trouble with third party code, more often than not it's way more complex than it needed to be)

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Honestly that's because most programmers are just lazy and would rather commit code as soon as the unit test bar turns green and receive their "most productive employee of the month" award than read over their code and spend some time reviewing it to see what could be made better.


Really?
You are going to pull the 'programmers are lazy' bullshit out of your arse?

Seriously, I expect this on a 'gamer' forum but on a developer one? jesus...

Has it ever occurred to you that the reason the code goes in when it is ready and isn't gone over to hell and back is because said programmer has various managers higher up the chain breathing down their neck to get shit done yesterday?

You ask what happened to craftsmanship? People want shit yesterday that's what happened.

Plenty of talented people out there are still trying to do the best they can but don't get a chance because higher up the chain 'good enough' is what they want and its on to the next feature. I've lost track of the number of things I've had to check in where I know I could have improved it but the time wasn't there because 'feature Y' needs to be done in a week now. You fight the battle, some times you win and more often than not you lose.

Christ...

This topic is closed to new replies.

Advertisement