Sunday, October 07, 2007

URL syntax and folders

The directory, or folder, is a central feature of every operating system. Windows Explorer is one of the most used applications on the planet, showing the contents of each folder and allowing document navigation.

And yet, on the web there is no such thing as a "folder". Click on "www.yahoo.com/finance/" and you don't see a list of all the documents in the finance folder - you see a webpage. If you're looking for a particular item, you don't navigate a hierarchy - you type a search.

The only enforced hierarchy is in the domain name - "www" is part of the "yahoo" domain inside the "com" top level domain. This hierachy is part of DNS, and is used so that the correct server responds to your browser.

"/" is just another character

Check out the URL http://blog.jonudell.net/2007/05/24/restful-web-services/. Do you think that on Jon's server, there is a "2007" directory, under which there is a "05" directory? No - the complete path "2007/05/24/restful-web-services/" is just a string parsed by the server, so the relevant resource can be displayed programmatically.

"/" is just another character in the URL path. Jon could have used "." instead, or even removed it altogether: "20070524restful-web-services". Everything is flat on the web.

The only reason why Jon added the "/" is convention - when people see the URL, it helps them understand what they might get if they click on it. "/" is a common convention to indicate hierarchy.

So the "/" does NOT represent directory structure.

What if I want web folders?

The main thing that folders provide is the ability to view the set of documents in a collection (e.g. all the pictures in an "images" folder).

On the web, there's a technology that solves just this problem: RSS. And it's far more flexible than a one-dimensional directory hierarchy; you can have RSS feeds for

  • all photos of green flowers
  • all photos of any green objects (including flowers)
  • all photos of flowers of any colour
Try doing this with folders - it's impossible!

In that respect, the URL and RSS feeds can support every navigation method: search, tagging, and hierarchy.

No more folders?

There are two major issues with folders. The first has already been mentioned: they are one dimensional, and therefore don't support modern techniques such as search and tagging. The second issue is that they're not scalable; if you've got a million (or even a billion) documents, navigating up and down the hierarchy to find your file takes way too long.

So it's a great thing that web was designed without folders. Instead, a combination of URL syntax conventions and RSS provides far better flexibility and power.

No comments: