writing resource oriented apis does benefit quite a bit, as it often forces you into good api patterns around idempotency. many aws apis and almost all new ones follow this pattern and they are much betterto integrate with because of it.
Yeah, def getHandler() = { val a = randomString() + readDatabase(); writeDatabase(a); return a;}
However that doesn't mean it's a good implementation. What you're doing there is gonna break caching for example, unless that's intended. If I'm calling a `GET` and your service is behaving like a `POST`, I'm not gonna be able to rely on standard semantics for a lot of things!!!
See section 9.1.2: Idempotent Methods, where they succinctly address the point:
> Naturally, it is not possible to ensure that the server does not generate side-effects as a result of performing a GET request; in fact, some dynamic resources consider that a feature. The important distinction here is that the user did not request the side-effects, so therefore cannot be held accountable for them.
-
It's funny, I wouldn't have thought the RFC needed to say this. I'd have thought it was a waste of words since it'd be obvious to absolutely anyone that you can't... what? magically force developers to not write a bit of code in a system you have literally no control over?
Yet here we are, proving the authors well-prepared all these years later.
Of course it's possible, there are ways to guarantee that and to prove that. That's an area of ongoing research. E.g. https://link.springer.com/chapter/10.1007/978-3-642-36594-2_...
Though I've said just one thing - you can't expect that a GET query would be idempotent. You may only hope.
Depending on your model it can be proven.
Electricity consumption won't be a side effect in any reasonable model.
Surely this is a troll...
If fact the latter is better, because it may be somehow enforced by cogen if you code-generate into a language which may, for example, enforce purity or totality.
And the whole story about "REST not being an RPC" or "there is purity/idempotence/whatever in REST because RFC says that GETs are pure/idempotent/whatever" makes very little sense.
At the same time I'm saying that it's total bullshit when someone says that it's not possible to enforce lack of side effects (like in referential transparency) during a remote call.
It's such an off-the-wall connection I can hardly refute it: it's like we're talking about toasters and you dived into talking about CRISPR because I said the word "crispy". If anything it'd imply you're not familiar with CRISPR or toasters.
> Though I've said just one thing - you can't expect that a GET query would be idempotent. You may only hope.
I guess you should look up what it means to expect something. In the context of your sentence hope and expect are synonymous*, so maybe you meant you can't guarantee?
And even ignoring that mistake, it's not really useful to say "You can't be sure something doesn't follow guidance, you can only expect it" because that's tautological. Guidance in and of itself doesn't have any way to assert direct influence on an implementation, that's why it's literally called guide·ance.
*before you use that to dive into a grammatical diversion, that is not generally the case, only specifically in your use.
Let's assume we make a remote call with a list of VM instructions for a virtual machine which has no access to any I/O. Now we only need to prove the correctness of the answer. Whatever you do on the remote side, you won't be able to make your computation impure. Yes, you still may write logs or sleep but it won't break referential transparency, there will be no way to return two different accepted results for the same inputs.
You may even have I/O in some very limited form.
You don't have to supply the code.
If you don't agree, show me side effects in EVM.
> In the context of your sentence hope and expect are synonymous
Only in your eyes.
Anyway, I've been saying that REST is too unformal and weak-typed.
You implicitly revised your previous statements, and the revised point is even further off base (I mean, now you're showing you don't know the difference between REST and HTTP verbs?)
At some point just take it as a learning experience that hamfisted non-sequitur about verifiable computing don't have any of the "shock and awe" on HN that they might on and your Facebook wall...
You should stick to things you understand if you insist on making authoritative statements.
-
By the way: language doesn't only work "in my eyes", words have meaning, learn those meanings before you use them.
> You should stick to things you understand
Ok. We don't need VC, for practical purposes we may do a lot of contract enforcement at the tooling level, like if we generate code from an IDL, we may restrict access to various APIs, enforce purity and totality.
> you don't know the difference between REST and HTTP verbs?
It doesn't matter if you talk about REST or HTTP, nothing guarantees "idempotence" of GET. Also the discussion was in the context of REST as something opposed to RPC.
> learn those meanings before you use them.
You command too much.
If you're willing to ignore the rules you can get away with pretty awful stuff that no one should really need to account for in a general conversation.
This is a common cache busting technique. Why is it a bad thing?
If you have the option between cache busting and just using the correct HTTP verb, please choose the latter.
As to whether there was an option in this particular case, I think the fact I referred to it as a "truly truly awful codebase" should provide a hint.
YMMV, however.
In 2017 I left to join Azure, which is REST-heavy (in all this, I mean "modern" REST, not "Fielding" REST). I hated it at first, but eventually saw how nice it is to have the conventions. Less to explain in public API docs, easier to generate scaffolding, common themes of how to destructure incoming requests in middleware handlers and middle-tier services, a standard way to serialize references to resources across the platform. I was a convert.
Moving to google in 2021, they're still very RPC, and it feels so cluttered and arbitrary. I'm not there anymore.
Yes, REST is roughly just some conventions around RPC at the core (though you get things like caching for free), but ultimately it's a really nice set of conventions that are easy to follow and limit surprise, and are standard across the industry. As one user commented, you do sometimes have to work around REST to get it to fit, typically futzing in headers or request metadata, but to me the pros outweigh the cons.
Azure's APIs are more RESTful than most: they actually bother using resource URLs as identifiers.
I've never understood what people find so hard about HATEOAS. It's like people have never interacted with a HTML form or followed links to stuff, or have difficulty figuring out how webpages can consist of multiple linked resources.
Or that an object graph of a system is a web of linked resources, and that every program has an entry point object/interface from which you can navigate to any part of that object graph, just like in REST.
The way Azure does it is kind of nice (to me at least, as an ex member of ARM) because ARM can generically check access just by the URIs. The downside though is that the URI also includes the subscription and tenant id, so ARM has to deal with the URI being stale after stuff gets moved around. And then the advent of management groups and cross-tenant access made it so it's not quite so straightforward anymore. But it was still quite useful.
Now the question is: Why do people insist to calling some (no standardized) ad hoc RPC protocol "REST(full)"?
Idempotency is not exclusive to REST. When you invoke File-Save twice in Notepad it doesn’t create two different files either.
You would have to encode your app-specific logic in every proxy or load balancer. In HTTP, they already exist.
The top two comments in this thread explain this more:
By using a proper protocol.
Not everything is nail just because the modern thin-client is only able to wield the HTTP hammer.
HTTP GET is idempotent, which seems trivial, but it's worth more than people think. With JSON-RPC you can't safely retry any RPC, and that matters at scale! (If the transport is HTTP, I'm pretty sure all JSON-RPC are POSTs. JSON-RPC can be good for local communication like language servers, where you don't really care about retrying or caching)
FWIW Google had/has a very RPC-like model, and when I left many years ago there, I remember they came around to giving explicit guidance to use a REST-like model (which you can do in an RPC system). That is, where you have more nouns than verbs, and you GET nouns.