KBD

Keith Devens .com

Saturday, July 4, 2009 Flag waving
Mistakes were made. – Ronald Reagan
← FirebirdPerl inflexible with abstractions →

Daily link icon Tuesday, June 3, 2003

Why I don't grok (XML) namespaces

Here's why I don't grok namespaces. First, some context:

"Sam Ruby didn't get everything he wants in RSS 2.0, neither did Tim Bray. They both want the same thing, the ability to include elements of RSS in other XML formats.

As I understand it, namespaces were intended to make possible exactly this.

So, supposedly you have some standard XML-based markup language (SXBML), and you want to include a document of some other standard XML-based markup language (SOSXBML) inside an SXBML document. So as to not "pollute" your pure SXBML, you distance yourself from that foreign markup by saying "Hey, he's not with me", and you partition it within your document using a namespace.

You'll never want to include some XML that isn't part of some standard and therefore has no namespace, you see. And naturally, each of your standards has been defined by some magnificent schema that encapsulates all the semantics (meaning) about every tag. This lets you use automated tools that magically know what to do with your document.

Yeah, right.

Well, if a computer can't divine what to do with a piece of XML without having code written by a human process it -- the human's mind is the only place where the "meaning" of the XML can be said to be known, not in some "schema" -- then what does the namespace give us (besides a headache)? I say nothing.

If I nest one document within another, the human programmer understands this. It doesn't matter that a tag is preceded by some alphanumeric characters and a colon, which form a string that the XML document says is used a certain way within the document and points the reader towards some globally, interplanetarilly, universally unique string that... well, what does that string do for us?

I'm just sick of everybody trying to write some labels down (that's all an XML document is) and claim that it has some "meaning" apart from a mind understanding it. A mind can understand the document just fine whether the label it's understanding is xhtml:body or xhtml-body. And therefore the code that a programmer writes with that understanding can work with either equally well.

E-mail headers, MIME, HTTP, etc. have gotten along fine by using X- headers for non standardized extensions. And in practice you can make up whatever you want and it doesn't matter. But what if two people use the same name? A standards body is supposed to make the official list to keep that from happening for anything that counts. I probably wouldn't get the standards organizations to recognize a Keith-is-awesome: e-mail header. Nor Slashdot's Futurama quote http header. So the developers of XML wanted to distribute this authority. XML lets people define their own namespaces for their custom name, and then the person putting together the final "document" can associate each piece with a namespace so that there's no conflict

The problem is that XML has gone and distributed both ends, which is just silly. XML makes it possible for anyone to be their own standards body for their own personal SXBML, and at the same time anyone else can make a tag for that standard. But what kind of standard is it anyway if anyone can go making his own tags? How can he expect his tags to magically work without a community consensus? A community has to decide collectively what something means for there to be interoperable software written. It seems like people are trying to have a "schema" decide meaning, rather than what works: "rough consensus and working code".

Update: Keep in mind that namespaces in programming languages serve a very different purpose than they do in markup languages like XML.

In source code, the authority to name things is distributed only on one end, not two. So, anyone can write code, but if another person wants to use that code he has no control over what names were used. It's sort of the opposite of the HTTP and MIME example. Namespaces in programming languages are an important feature, so it seems that distribution of authority on one side works, just not two.

Namespaces serve a significant function in programming languages. They help prevent name conflicts, and that's important when you want to include code that (possibly many) others have written along with your own code, since, unlike with SXBML and unlike with HTTP or MIME, there's no central standards body defining what names you can use for things. That's why Java's convention is to provide code in packages identified by globally unique strings. Everyone can have their own namespace.

Namespaces aren't always called that, however. Some languages call them "modules", some "packages", others simply use classes as the basic form of namespace, and some provide "namespaces" explicitly.

Namespaces in programming languages are especially important for another reason as well. Source code is generally very flat, often just one level of functions, and maybe one level of classes. Markup languages like XML, on the other hand, can nest to any depth. That's why languages like C++ and PHP have explicit namespaces, or are getting them. Both languages don't have any higher level packaging mechanism other than the class, and both also allow plain functions outside of a class.

← FirebirdPerl inflexible with abstractions →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

July 2009
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
262728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 3 posts

Recent comments XML

new⇒Wizard's First Rule

> while it is cheesy to some​extent, I actually found it to be​pretty enjoy...

Keith: Jul 3, 6:33pm

I hate Norton Antivirus

I bought Norton 2009 and it is not​installing on my computer!!!
It​seems l...

o'neil: Jun 30, 11:44am

Generated in about 0.222s.

(Used 8 db queries)