Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The semantic of a computer language (and a markup language in particular) is what the code does with it. Sometimes the code uses whitespace and sometimes it doesn't; XML doesn't enforce either way and leaves this up to the app. When necessary you can explicitly mark your preference in different parts of the tree with the 'xml:space' attribute. This attribute has precise and unambiguous semantic. It is also another example of why namespaces are important: it's a universal attribute that can be used with any XML document, by the virtue of namespaces it will never conflict with anything, it has a clear and small area of responsibility so any software vendor can easily implement it, you don't need to invent your own conventions or whatever, just reuse it.

By comparison, HTML has almost no semantic. You have no idea what the code (which code, by the way?) is going to do with your 'article' tags or tell exactly how 'nav' is different from 'menu'; this spins endless debate about which tag to use. I remember how people argued that using 'dl' for figures with captions was, you know, "semantic markup" :) This is not semantic markup. Semantic markup would be things like <date:timestamp value="..." /> that a browser would render in my timezone or <chess:position move="white">...</chess:position> to describe a position on a chessboard so that a search engine could find similar positions or chess parties where this position has occurred. This is semantic markup and this could be semantic Web. And to make this happen we need to be able to develop small and clearly specified mini-languages with precise semantic (=computer instructions) and then mix them in a single document and this is what namespaces are for. This is the vision behind XML. It's very sad that few people grok it; most prefer to badmouth things they don't understand.

A proper markup language should either be low-level and describe, for example, physical layout and such, or should be extensible so I can describe the document in my own terms! I do not write a bunch of divs and h1s, I write, for example, docs for a function with <synopsis>, <parameters>, <examples>, maybe <notes> and so on. And then I mechanically convert it into a low-level language for rendering. HTML is neither: it's not low-level, it's very hard to control even the visual appearance, and it's not extensible either. It's bad in all aspects.

(Also, XML not only describes marked-up text, it's the only practical way to work with such text. All modern publishing uses XML.)



> All modern publishing uses XML.

Okay, just because you don't like HTML5 doesn't mean you get to deny that it exists.


Is that all you can say? It does exist, but it isn't much better than it was in v4. A few more canned tags; big deal. I wonder why the minor syntactic differences were so important though. Is it that hard to close a tag? And why no empty tags, they're certainly more concise? These are probably rhetorical questions. Sure HTML is superb; you still have to specify the time of your upcoming webinar as plain text so the users from other side of the world would have to look up what the WTF timezone is, but I'm sure there's a tiny half-megabyte JS library with a clever regex to fix this.

XML is the only sane format to deal with marked up texts written in natural languages, and this is precisely because it is extensible, so you can describe the structure in terms that make sense to the subject matter and still be able to process it with standard tools. It's also a perfect format for parsing results, because XML is essentially a frozen syntax tree. HTML is just a single fixed language; it's widespread and popular but not because it's technically superior (same as JS and CSS).


You really want me to say more?

You seem to have missed the point of my reply. You said "all modern publishing uses XML", and in doing so, you were overlooking the biggest counterexample to XML, and the biggest thing in modern publishing, which is HTML 5.

HTML is a huge, huge example of modern publishing. It tried XML, when HTML 4 came along with XHTML. XML was basically designed around making XHTML work. And then HTML stopped using XML in HTML5. It took a revolt of all the implementers of HTML, but people got behind it because everyone could tell that XML wasn't helping.

So now you've got a syntax that was designed for marked-up documents, that people don't really want to use for marking up documents, and it's also trying to convey data structures despite that this involves horrible patches like "xml:space" that no other format needs.

You were also hinting at APIs for communicating things like time zones and chess moves. Real APIs don't use marked-up natural language. I work in natural language processing, and to a first approximation, computers don't understand shit about natural language. When you need to communicate data, you use data structures.

If you want to communicate extensible data structures with hints about their semantics, you've got some choices, like protobufs and JSON-LD. Or you can keep patching XML and trying to make it convey data structures despite that data structures aren't made of marked-up strings, but then people won't use your API.

XML is also an unwieldy format for parse results. It's not a frozen syntax tree, it's a tree with tons of stuff bolted on to the side. The format that represents a syntax tree is S-expressions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: