3 ms·
The goal of REST isn't to be the RPC protocol. It is to be lower level protocol which uses simple verbs to transfer state. For example, SQL has simple verbs be
by lmilcin 6y ago
The goal of REST isn't to be the RPC protocol. It is to be lower level protocol which uses simple verbs to transfer state.
For example, SQL has simple verbs because it doesn't want to know what are the actual operations executed by the application (for example, verifying status of an existing process, checking optimisting lock, etc.)
Another example are some remote memory interfaces which basically transfer blocks of memory back and forth without knowing what is the operation for. You build your higher level, business logic-aware protocol on top of it.
The same way, REST is about intentionally not getting involved with the imperative style and instead provide transport protocol that will make it possible to refer to the things as resources, discover resource graph through hyperlinks, etc.
The business logic is supposed to introduce changes to the object but use REST to only transfer representation of the changed state (Representational State Transfer) without burdening it with RPC details.
That is why so many APIs fail to use REST effectively, because designers do not understand the goal and limitations of REST. It is conscious decision not only what the API does but also what it is not supposed to do.
To update the user the REST-ful way would be to allow the client to fetch the user document, introduce changes client side with whatever logic the client wants and then transfer the representation of modified state back to the server with a simple verb (same way we interact with filesystem through reads and writes without kernel ever knowing what this is). The server decides what to do with these changes.
Trying to burden the kernel with information about what the operation is is futile but that's what usually happens when people design "REST"-ful APIs.
- WClayFerguson 6y ago> The goal of REST isn't to be the RPC protocol I'd politely disagree with that. I think most REST fanatics ACTUALLY DO claim that their beautiful arrangement of nouns and their 4 CRUD verbs are capable of replacing RPC, because they've become convinced the "procedure" part of RPC, means that RPC is inherently built around functional programming which is verbs, and they think they've found a better way than using a custom vocabulary of verbs. So they're using REST instead of RPC, because "verbs are bad". I'll just restate my opinion that the concepts of "functional programming" are not somehow rendered obsolete whenever the machine you're talking to happens to be remote. Sure, there are certain challenges involved with designing a 'remote' API that can arise involving latency and bandwidth considerations, but those limitations in no way imply a solution where you throw out your entire set of "verbs", like REST does.
- tsimionescu 6y agoI think that REST is the language of your API. Just like in a regular PL you normally have just a handful of verbs, as I said in my first answer, so to in REST you only need a few verbs. Of course, you then build up functionality over those base verbs, just like in a program. But your programming language doesn't have a verb for each function you might want to write. It just has the base 'call' verb.
- WClayFerguson 6y agoI've said everything I know to say, 10 different ways all over this thread. It's a topic lots of people have strong opinions about for sure.