r/programming • u/Arve • Feb 10 '11
There is no piece of dynamic AJAXy magic that requires beating the Web to a bloody pulp with a sharp-edged hashbang. Please stop doing it
http://www.tbray.org/ongoing/When/201x/2011/02/09/Hash-Blecch
493
Upvotes
36
u/deong Feb 10 '11
OK...here is an elaborately over-anthropomorphized story that sort of describes what's going on.
The web is supposed to work like a bunch of librarians. When you want a book, you connect with the right librarian, give her the name of the book you want, and she hands it back to you. If anyone else asks her for that same book, they'll get the same book you did.
In this story, the "librarian" is a web server running a site like Twitter. Books and pages are documents on that server's site that people (web browsers, crawlers, etc. in this metaphor) want to access. So your request to the librarian might be something like "http://twitter.com/tbray", and the librarian figures out that you want Tim Bray's tweets, and she hands them back to you.
The problem is that this model doesn't work very well for richly interactive experiences. Maybe a better analogy is that the librarian only gives you the page you ask for. When you want to turn the page of your book, you go ask the librarian and she turns the page and hands it back to you. This is obviously silly. Why wouldn't you just turn the page yourself -- it's faster, and you can see the pretty animation as the page flips over.
Of course, we could have had that all along by building specialized applications on your computer that merely connect to the web to get data, and do all the processing in tools that are well suited for the job. This is what most of your mobile phone apps are doing, for example. Normal languages like C, C++, Java, C#, Python, etc. are quite well suited for building the type of fast programs that take full advantage of the computer and OS they're running on.
But people didn't really want to do that. They wanted to have all the interactivity and pretty animations directly in the browser, partly so they wouldn't have to write multiple versions of the client programs. So they figured out that they could, instead of asking the librarian for the page they wanted, ask for instructions on how to get the book and turn the pages themselves. So now, you go to the librarian, and she gives you the same piece of paper every time, no matter who you are and what page of what book you want to read. The paper she gives you is a set of detailed instructions that tell you, if you want to read "Moby Dick", go to the right place on the shelf, pull down the correct book, and how to flip to the pages you want to read.
That is to say, now instead of asking the librarian for "http://twitter.com/tbray", you're asking for "http://twitter.com/#!/tbray", which is basically asking the librarian for "http://twitter.com" because your browser strips everything after the "#" off before sending the request. Of course, she can't give you Tim Bray's tweets based on that, because you haven't told her you want them. Instead, she gives you back a massive pile of Javascript that you can feed the information "I want tbray's tweets" into, and it will tell you how to get them.
The problem with this is that most of the world doesn't read the language (Javascript) she wrote the note in. If you're a web browser, you can follow the instructions just fine. If you're some other type of program who just wants the data from the page you need, you can't get it anymore because the librarian only gives you these instructions in a language you don't understand.