3 ms·
XML have redundancy by design. It's a deliberate trade-off to make it easier to read and write by hand, at the cost of size. If message size is an issue then g
by olavk 18y ago
XML have redundancy by design. It's a deliberate trade-off to make it easier to read and write by hand, at the cost of size.
If message size is an issue then gzip the data. Or if you have very specific needs for processing speed, look into something like Googles protocol buffers.
You are optimizing at the wrong level if you are concerned about a few extra characters in a human-readable data exchange format.
- BrandonM 18y agoBut is it really easier to read and write? Properly-indented S-expressions are just as readable. Generating XML and then gzip-ing it is a lot more work (and requires a lot more libraries) than generating S-expressions. Case in point: <table> <tr> <td>a</td> <td>b</td> </tr> <tr> <td>c</td> <td>d</td> </tr> </table> vs: (table (tr (td a) (td b)) (tr (td c) (td d))) Perhaps the real problem is that too many people use terrible text editors. Paren-matching and auto-indentation makes writing S-expressions orders of magnitude easier, and at least a constant factor easier than writing XML.
- olavk 18y agoYou are right about text-editors. XML was designed to be reasonable easy to write and edit by humans without specialized software. The redundant end-tag helps to catch errors and make structure more explicit. Sure everyone could just use a fancy specialized editor with paren-matching auto-indentation. But one of the goals of XML was precisely that it should not rely on specialized software to be able to read and write. Your example with the table is a lot clearer with sexpr syntax because you don't actually have any content in the table. Try again with a few sentences of mixed content, some bolded words, a link, and so on, and you will get my point. Note that you would also need to gzip your s-expressions if you are concerned about size.
- BrandonM 18y agoThe HTML of your comment, with some formatting added: <span class="comment"> <font color=#000000> You are right about text-editors. XML was designed to be reasonable easy to write and edit by humans without specialized software. The redundant end-tag helps to catch errors and make structure more explicit. <p> Sure everyone could just use a fancy specialized editor with paren matching auto-indentation. But one of the goals of XML was precisely that it should not rely on specialized software to be able to read and write. <p> Your example with the table is a lot clearer with sexpr syntax <b>because you don't actually have any content in the table.</b> Try again with a few sentences of mixed content, some bolded words, a link, and so on, and you will get my point. <p> Note that you would also need to gzip your s-expressions if you are concerned about size. </font> </span> The same thing in S-expressions (an invented syntax): (span (class . comment) (font (color . #000000) You are right about text-editors. XML was designed to be reasonable easy to write and edit by humans without specialized software. The redundant end-tag helps to catch errors and make structure more explicit. (p) Sure everyone could just use a fancy specialized editor with paren matching auto-indentation. But one of the goals of XML was precisely that it should not rely on specialized software to be able to read and write. (p) Your example with the table is a lot clearer with sexpr syntax (b because you don't actually have any content in the table). Try again with a few sentences of mixed content, some bolded words, a link, and so on, and you will get my point. (p) Note that you would also need to gzip your s-expressions if you are concerned about size.)) It's really not a lot different. Of course, parens would need to be escaped, but this is no different from needing to escape < and >. But one of the goals of XML was precisely that it should not rely on specialized software to be able to read and write. But this is the problem with XML... it does rely on special libraries to validate and parse into reasonable data structures. It requires special heuristics to describe how to recover nicely in the event that markup isn't valid. It requires a document describing exactly what the XML needs to look like. S-expressions are easier to parse, less verbose, and can accomplish all the same tasks and more, all while being more flexible in general.
- jamesbritt 18y ago" Paren-matching and auto-indentation makes writing S-expressions orders of magnitude easier, and at least a constant factor easier than writing XML." Funny; I find that the tag matching, auto-indentation, and auto-completion in vim make editing XML pretty easy. Maybe S-expressions are slightly easier. Maybe not.