3 ms·
(disclaimer: TFA is dead for me right now so I might be speaking out of context) REST (like "object-oriented programming") is an ambiguous term that might refe
by philwelch 8y ago
(disclaimer: TFA is dead for me right now so I might be speaking out of context)
REST (like "object-oriented programming") is an ambiguous term that might refer to a reasonable and usable subset of behavior, or it might refer to a more extensive hypermedia-style design pattern.
REST, in the hypermedia sense, and in the sense of "the design principles behind HTTP in the first place", is a good way for a server to expose data to an intelligent human-guided client (i.e. a web browser). It doesn't do a lot for the API case, but it does a little and there's enough tooling to get you the rest of the way.
I usually don't even think of REST API's as RESTful. I think of them as RPCs that exchange JSON, except you define the RPC endpoint as an HTTP verb/URL pattern tuple, accept and treat as a contract the standards behind different verbs, use response codes for out-of-band metadata, and piggyback on all the tooling and infrastructure that people already built around serving HTTP to web browsers in the first place. If you want to strongly type your RPC, you can use OpenAPI. If you want to define your RPC ahead of time and then generate server and/or client code from a definition, you can use Swagger Codegen. There's enough adequate tooling that you don't necessarily need to resort to an actual RPC protocol, but that doesn't mean your REST API actually has to be RESTful in any meaningful way, or even that it should be.
- weberc2 8y ago> is a good way for a server to expose data to an intelligent human-guided client (i.e. a web browser) A web-browser doesn't have any concept of REST; it only provides a sandbox for the client code which knows how to map paths to data (but pretty much never does so by means of any sort of introspection). Note that this isn't advocating against REST or in favor of RPC, just a neutral observation.
- deleted 8y ago[deleted]
- munk-a 8y agoActually the original, core, really REST thing (that almost no one views as REST anymore) is all about resource exposure, and a dumb browser doesn't know how to interact with it but a REST aware generic browser could potentially interact with RESTful endpoints without other assistance. I'm specifically talking about the portion of rest that includes delivering actions with noun results, i.e. "Here's you comment record, if you want to edit it go to this URL, if you want to delete it here's a different one". Also, I, personally, find that portion of REST to be silly. I like the organizational hints and guidelines, but the resource discovery seems far too pipe-dreamy to ever be built on a large scale.
- philwelch 8y ago> I'm specifically talking about the portion of rest that includes delivering actions with noun results, i.e. "Here's you comment record, if you want to edit it go to this URL, if you want to delete it here's a different one". How does that not describe a normal HTML page that has "edit" and "delete" links right next to the newly-created comment that it displays to you after you click the "reply" button on Hacker News? I mean, it's not automatic discovery, because you're relying on a human being to read a rendered web page and know what the links mean, but it kind of qualifies if you expect that the client is partially made of meat.
- munk-a 8y agoThat's sort of the point, it was to remove the meat requirement on discovering those. Making the edit/delete/whatever forms and requirements machine readable so a stronger but still generic client tool can interpret them more intelligently. Again, I think it's naive since while a lot of stuff has plain CRUD operations, there are entities in most webapps that have more complex operations. If I were writing an application that partially managed cutlery in a restaurant it's not clear where a "clean" verb on a fork would fit into REST and how a generic client would understand what significance "clean" has especially as it relates to future eat actions. I have read through and understand the intent of the original RESTful system and I think there are some good and bad points. But, automatic discovery was definitely included in their vision of how it'd work, and actually seems like the center point TBH.
- philwelch 8y ago> That's sort of the point, it was to remove the meat requirement on discovering those. Making the edit/delete/whatever forms and requirements machine readable so a stronger but still generic client tool can interpret them more intelligently. Hmm, that makes REST sound like it's pursuing similar ideas as the Semantic Web. > Again, I think it's naive since while a lot of stuff has plain CRUD operations, there are entities in most webapps that have more complex operations. If I were writing an application that partially managed cutlery in a restaurant it's not clear where a "clean" verb on a fork would fit into REST and how a generic client would understand what significance "clean" has especially as it relates to future eat actions. It isn't clear at all. It's possible, but in weird, hacky ways. Maybe when you're done with a fork, you DELETE the fork and then you can POST to /clean_forks/ to create a newly cleaned fork. And if you run out of forks to clean, it throws a 503 error. It's a terrible Kingdom of Nouns (https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html https://steve-yegge.blogspot.com/2006/03/execution-in-kingdo...) but it might appeal to some people, for the same reasons that the original Kingdom of Nouns appealed to some people. After all, you get to feel clever and smart when you invent new design patterns to work around the limitations of your technology. Just writing a `clean_fork` RPC doesn't make you feel clever at all. In any case, while I can see automatic discovery as a useful feature for web browsers (who can still punt the actual decision-making to the meat, as long as they know what the plausible next steps would be), it doesn't seem likely to me that service clients would benefit from it any more than they benefit from a thoughtfully designed and documented RPC API. Meanwhile, for whatever reason, the end-user-facing web has decided to prioritize the use case of, "you will see and interact this web page according to The Original Creative Intention Of The Author" over the use case of, "here, have some data, it links together, do whatever the hell you want with it, I don't care what fonts or UI widgets you use". REST would have been great for the second use case; it's just that nobody cares about it anymore.
- geezerjay 8y ago> REST (like "object-oriented programming") is an ambiguous term It really isn't. There's a whole doctoral thesis describing in detail what REST is and what it is supposed to achieve.
- evgen 8y agoA thesis that we are all welcome to ignore. REST means exactly what we (collectively) decide it means. Sorry if this bugs the pedants in our midst, but no one really cares too much that they are using REST 'the wrong way' when it is just another tool to be used to get the job done.
- geezerjay 8y ago> A thesis that we are all welcome to ignore. That just means that ignorance is leading clueless developers to misrepresent a specific concept by talking about stuff they know nothing about. Not knowing something is not the same as something not existing.
- Communitivity 8y agoREST is exactly what Roy Fielding defined it as, in https://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm https://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm. Anyone is welcome to do something different, but similar. However, in the name of sanity, don't call it REST/REST-like/REST-ful/etc. Instead, give it a new name and say it is based on (or derived from REST). Give credit where due, but have the courage to name it a new thing. Like SOA, and Agile, REST has had a proliferation of APIs claiming to be REST or RESTful, when they are not. To do otherwise is all of: an insult to Dr. Fielding, a muddying of the term REST, a disservice to the developers using your API, and a disservice to yourself (because you have created something new).
- ionised 8y agoSpeak for yourself.
- droussel 8y agoWhat's wrong with you? The thesis is where the word was actually defined! You can't just run around inventing new definition for stuff. No wonder we live in a post-truth era: https://en.oxforddictionaries.com/definition/post-truth https://en.oxforddictionaries.com/definition/post-truth