Thursday, March 23. 2006
Kicking the RESTafarian beehive... the score thus far:
Whoah. Lots and lots of action is happening in the blogosphere about the division between Hi REST and Lo REST (which I argued is completely bunk, and still do).
First off, I should mention Koranteng Ofosu-Amaah who, like me, is all about the Elevator Pitch of REST, which he puts a whole lot more succinctly then I did. Good on him.
Mnot also talks about the false choice, but then we go right back into the conversation about which HTTP verbs to use.
Enough funning. The real part that merits a response is that having meaningful conversation about REST Is hard, because there is a real disconnect between what REST means and what people think REST means. In fact, I don't so much have a problem with the idea of splitting REST into a high and low version. What I take issue with is where the split is taking place. For instance, I could see a situation arise where cookies would be used to store an applications state, and this could still be RESTful, and we could call that Lo-REST. I would even go so far as to say that we could break one of RESTS constraints and we can call that Lo-REST. But the point is, that in order to make this Hi and Low REST distinction, we have to be talking about REST, not HTTP. In fact, One could argue that one doesn't need to use HTTP to be RESTful, and it seems to me that Fielding suggests as much in his dissertation when he talks about REST being applied to URI and HTTP.
Another excellent thing that Ryan brings up is the fact that the response entity of the server does not have to be XML for it to be rest. In some cases, a text/plain will be a perfectly valid, and usable resource representation. He also brings up Microformats as a good resource representation (AHAH is what this is called, and it is quite nice actually).
I guess as an analogy it works really well with SOAP, since SOAP started out as the Simple Object Access Protocol after all. But I think that the analogy can be carried further, and perhaps expressed differently in the case of REST to promote more understanding (which is not to imply that Sam Ruby doesn't understand REST). When you GET /resource?my&query&string&here, what you are really doing is $myRepresentation = new Resource($my, $query, $string, $here)... and at about this point the analogy starts to break down. POSTing to a resource will perhaps alter the resource itself (thus changing the class), or it may just alter the representation of the resource (changing an instance, and all future instances that "look like it"), or, it may just initiate an action leaving the state of the resource unchanged, but otherwise modify or act on another resource. If you perform a DELETE on a resource, one of the actions that may happen is that a representation of the resource disappears, likened to unset($myRepresentation). But another thing that might happen is that the resource itself will disappear. The only analogy here is that you undefine a class (which only makes sense in a world where classes are first-class entities).
It is in the breakdown of the analogy that (hopefully) promotes more understanding. Essentially what I am saying is that with REST you don't want to think about methods on objects, you don't want to think about storage and retrieval of documents, you want to think about Actions on Universal Resource Indicators, that may contain a representation of a resource, that may return a representation of a resource. From Fielding:
First off, I should mention Koranteng Ofosu-Amaah who, like me, is all about the Elevator Pitch of REST, which he puts a whole lot more succinctly then I did. Good on him.
Mnot also talks about the false choice, but then we go right back into the conversation about which HTTP verbs to use.
Avatars and Definitions
I'd like to respond to someone on the "other side" of the discussion who is making a lot of waves, and, while I may not agree with what he has to say is zeroing in on some good stuff. Ryan Tomayko in his entry TitledThe Highs and Lows of Rest says:To which there are a few things to say. The first of which, why is the RESTafarian a PHP writing dirty hippy? Have I become some kind of RESTafarian avatar?
Not being able to distinguish which of these subsets of applied REST one is referring to is hurting our ability to have meaningful conversations about this stuff. For example, consider the following conversation; Ive seen it hundreds of times now:
Restafarian: 80% of developers use the XXX REST API because they find it easier to deal with.Id like that to stop happening.
Tool Vendor: Thats not really REST. It only uses GET and POST and breaks rule #5034
Restafarian: Oh yea, well SOAP/WS-* sucks.
Tool Vendor: Go write some PHP you dirty hippie!
But I dont think adopting wrong or ambiguous terminology is going to help either. Id like to register my nits with the few sentences that Dare provided and see if anyone else is thinking along similar lines.
Enough funning. The real part that merits a response is that having meaningful conversation about REST Is hard, because there is a real disconnect between what REST means and what people think REST means. In fact, I don't so much have a problem with the idea of splitting REST into a high and low version. What I take issue with is where the split is taking place. For instance, I could see a situation arise where cookies would be used to store an applications state, and this could still be RESTful, and we could call that Lo-REST. I would even go so far as to say that we could break one of RESTS constraints and we can call that Lo-REST. But the point is, that in order to make this Hi and Low REST distinction, we have to be talking about REST, not HTTP. In fact, One could argue that one doesn't need to use HTTP to be RESTful, and it seems to me that Fielding suggests as much in his dissertation when he talks about REST being applied to URI and HTTP.
Another excellent thing that Ryan brings up is the fact that the response entity of the server does not have to be XML for it to be rest. In some cases, a text/plain will be a perfectly valid, and usable resource representation. He also brings up Microformats as a good resource representation (AHAH is what this is called, and it is quite nice actually).
Web services as objects
Apparently my previous entry resonated with Sam Ruby as well, and through checking out his blog, I suddenly got transported into the world of Duck Typing and other misc goodness. Go check it out, you won't be wasting your time, he is on my feedlist. Sam Ruby makes the web-service to object analogy, which I like a lot more then the REST/CRUD analogy, but it still doesn't fit right with me.I guess as an analogy it works really well with SOAP, since SOAP started out as the Simple Object Access Protocol after all. But I think that the analogy can be carried further, and perhaps expressed differently in the case of REST to promote more understanding (which is not to imply that Sam Ruby doesn't understand REST). When you GET /resource?my&query&string&here, what you are really doing is $myRepresentation = new Resource($my, $query, $string, $here)... and at about this point the analogy starts to break down. POSTing to a resource will perhaps alter the resource itself (thus changing the class), or it may just alter the representation of the resource (changing an instance, and all future instances that "look like it"), or, it may just initiate an action leaving the state of the resource unchanged, but otherwise modify or act on another resource. If you perform a DELETE on a resource, one of the actions that may happen is that a representation of the resource disappears, likened to unset($myRepresentation). But another thing that might happen is that the resource itself will disappear. The only analogy here is that you undefine a class (which only makes sense in a world where classes are first-class entities).
It is in the breakdown of the analogy that (hopefully) promotes more understanding. Essentially what I am saying is that with REST you don't want to think about methods on objects, you don't want to think about storage and retrieval of documents, you want to think about Actions on Universal Resource Indicators, that may contain a representation of a resource, that may return a representation of a resource. From Fielding:
What distinguishes HTTP from RPC isn't the syntax. It isn't even the different characteristics gained from using a stream as a parameter, though that helps to explain why existing RPC mechanisms were not usable for the Web. What makes HTTP significantly different from RPC is that the requests are directed to resources using a generic interface with standard semantics that can be interpreted by intermediaries almost as well as by the machines that originate services. The result is an application that allows for layers of transformation and indirection that are independent of the information origin, which is very useful for an Internet-scale, multi-organization, anarchically scalable information system. RPC mechanisms, in contrast, are defined in terms of language APIs, not network-based applications.Notice that Fielding himself makes the HTTP vs. REST distinction here. (For clarity, what makes my above description RESTful is this talk about representations of resources.)
Cleaning up communication
It really is all about clarity of what REST is. REST is a general set of constraints that happen to be really well applied to HTTP. I happen to be working with an application server that is about 70/30 REST, its protocol has nothing to do with HTTP. However, it contains some (but not all) of the architectural constraints that are laid out by Fielding's dissertation.Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
I realize that this is offtopic, but your Atom 1.0 feed is not well formed:
http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fblog.jonnay.net%2Ffeeds%2Fatom10.xml
http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fblog.jonnay.net%2Ffeeds%2Fatom10.xml
I'm not trying to make waves, I'm trying to get things done. I've spent the last 3-4 years talking about how nifty REST is as an abstract concept. I'd like to start applying those abstract concepts to reality and the only place that's relevant to the web is HTTP. Often times you'll see "REST" used in a way that means, "some concept from the REST architectural style considered from the perspective of its current implementation status as deployed on the majority of the web using HTTP." This, coincidentally, is exactly what I was talking about in the post you cited. We lack the vocabulary to have meaningful conversations about the current state of REST as applied with HTTP on the web. Every time we start to talk about it, someone says, that's not "REST". Well, okay, but can we move on and start talking about that for which we refuse to assign a term then?
Please don't mis-understand. The making of waves is a GOOD thing. Whether or not I agree with the low/high definitions of REST, there is more conversation going on about what REST really means.
I think a large part of why some people don't like the lo/hi rest idea is that it focuses too much on the verbs of HTTP+REST, and not enough on the other constraints (state on client, representation of resources, etc.). That is why people are too quick to say "That isn't rest!". There is no reason why a system that responds only to GET and POST requests can't be restful. Along the same token, PUT and DELETE do nothing to make a system more restful if it maintains client state on the server.
I think a large part of why some people don't like the lo/hi rest idea is that it focuses too much on the verbs of HTTP+REST, and not enough on the other constraints (state on client, representation of resources, etc.). That is why people are too quick to say "That isn't rest!". There is no reason why a system that responds only to GET and POST requests can't be restful. Along the same token, PUT and DELETE do nothing to make a system more restful if it maintains client state on the server.
I never thought "hi" and "lo" were meant to specify that one was more or less RESTful than the other. I believe the original idea was simply to classify the more constrained applications of REST we see very commonly on the web vs. the more esoteric usages we see in up-and-coming applications like the Atom Publishing Protocol. Why are there so many of the first case and so few of the second? Why hasn't better support for anything not GET/POST made it into popular server and client side frameworks and libraries? (we *have* been trying, you know) Why aren't we using content negotiation? Why isn't it easier to store client state on clients? Why are people still tring to make up new URI schemes (feed://) instead of using media types properly? If you sit down and design a system based on the abstract concepts described in Roy's thesis with no knowledge of the web, what are the chances you then implement them on the web with the tools, protocols, and formats we have today and have people interop with you in an uncoordinated way? It's really not very good. This is why you don't see Yahoo! and Google using more considered forms of REST architecture. If you go outside of the verbs, media types, and client capabilities that the web has good support for today, you're lowering the adoptabitity of whatever you're designing. That's an important consideration.
Anyway, there's a gap between REST as described by Fielding and what one can reasonably expect to implement and have adopted on the web. I don't believe this says anything bad about REST or the web, it just means we need better tools on the client and server. We have a few catalysts (APP, Ajax, JSON, Microformats, etc) and I think the situation on the web is going to improve rapidly for at least the next 5-10 years. That doesn't mean I don't want a word for the RESTful web as it is today.
Anyway, there's a gap between REST as described by Fielding and what one can reasonably expect to implement and have adopted on the web. I don't believe this says anything bad about REST or the web, it just means we need better tools on the client and server. We have a few catalysts (APP, Ajax, JSON, Microformats, etc) and I think the situation on the web is going to improve rapidly for at least the next 5-10 years. That doesn't mean I don't want a word for the RESTful web as it is today.
Add Comment




