Live data from Hacker News

Who Cares about GET vs. POST? NoREST

swaxblog.tumblr.com

51–60 of 106 posts

Re: Who Cares about GET vs. POST? NoREST

#51

It would have been nice if he proposed something innovative moving forward, but this is a step back to RPC-structured APIs. After reading this though, I had to check to make sure it wasn't April 1st.

I think the whole point the article is trying to make is that REST isn't really a step forward from RPC. It just adds an overly restrictive taxonomy (i.e. in a complex practical application, you're probably going to run into a problem that doesn't fit the REST model well), and doesn't actually solve any real problems.

That may be the point of the article, but neither it nor any of the other instance of people making similar claims I've seen supports it convincingly.

Re: Who Cares about GET vs. POST? NoREST

#52
post #12

Except that RPC-structured APIs are complete garbage to consume for external developers because, surprise, they don't know or care what your internal function names are. And if you aren't thinking about the experience of real or theoretical third-party developers when building your API, why even have one at all? If you ignore HTTP verbs and status codes you're just making it harder for other developers to grok your s…

> Except that RPC-structured APIs are complete garbage to consume for external developers because, surprise, they don't know or care what your internal function names are. And if you aren't thinking about the experience of real or theoretical third-party developers when building your API, why even have one at all?

They don't care what the internal function names are but they do care about the language of the domain, and if the internal program is well written then those will be one and the same. The HTTP verb model is inadequate for domains of realistic complexity; imagine a developer looking for the method that flubbleizes the worzwort. Is this POST /worzworts/12345 ? PATCH /worzworts/12345 ? If you squint at it then flubbleizing is kind of like adding another bishwiggle, so maybe it's PUT /worzworts/12345/bishwiggles ? Most people tend to realize that these domain-specific operations don't have a HTTP representation and instead make them a POST with the specific operation in the URL. But then you end up with an api that looks like:

    #flubbleize a worzwort
    POST /worzworts/12345/flubbleize
    #mrefgle a worzwort
    POST /worzworts/12345/mrefgle
    #chezzle a worzwort
    POST /worzworts/12345/chezzle
    #delete a worzwort
    DELETE /worzworts/12345
This ends up being less consistent, and more confusing to a developer, than simply using POST for every operation.

> If you ignore HTTP verbs and status codes you're just making it harder for other developers to grok your system. It's less about adherence to some strict standard and more about helpful signaling. A GET fetches data, POST creates new records, PUT is idempotent, DELETE deletes. 4xx status codes indicate a request error, 5xx indicate a server error. That's all useful information for someone trying to integrate with your API, but you think that instead everyone should memorize your in-house conventions. Good luck getting buy-in on that.

The developer doesn't start by knowing that something is a PUT and trying to figure out what it's doing - they start by knowing what they want to do and trying to figure out the call. The world isn't consistent enough for them to be able to guess, and splitting the call into two parts - verb and path - makes it harder to remember once you've looked it up, not easier.

4xx vs 5xx is maybe valuable, but the very fact that you xx it suggests that the difference between 412 and 422 probably isn't important. In practice every REST API I've seen has felt the need to include a response body that a) explains the error and b) includes their own API-specific error code. In which case, why repeat yourself badly in the HTTP status code?

Re: Who Cares about GET vs. POST? NoREST

#53
post #30
post #18

Earlier quoted context omitted.

Why, are external developers able to consume restful APIs without the need for any documentation on the system they're talking to? Aren't the various REST entities (and all the possible links between them, if you're doing HATEOAS) already part of a protocol the developers of external consumers need to know beforehand?

Sure, that sounds nice in theory. In the wild, how many developers (especially those working on internal APIs) have the time & inclination to thoroughly document their entire APIs? And if it exists, many developers read the entire spec of an API before beginning development? In my experience both are rare. Given the constraints developers often find themselves under, having an API that uses common patterns most devel…

Note that this use of conventional URI structure patterns does have the value you describe, but is also completely orthogonal to REST (REST isn't about beautiful URIs -- the path part of the URI could all be UUIDs and you could follow the REST architectural style perfectly; HATEOAS, in particular, means that other than the entry point, your URIs should all be coming to you from other documents with their context in that document telling you what they are, so you don't need to parse the URI for meaning.)

Re: Who Cares about GET vs. POST? NoREST

#54
post #42

Earlier quoted context omitted.

I think you've inadvertently put your figure on the part that really matters. REST is worse than SOAP or something like Thrift for discoverability, worse for ease of use, worse for practically every criterion you could think about. The one thing it does right is being easy to explore with a web browser. So optimize for that. Make it easy for a developer to look at your API with a web browser. This means simple URLs.…

> REST is worse than SOAP or something like Thrift for discoverability How? > worse for ease of use How? > worse for practically every criterion you could think about. I can think of lots of criteria, but very few on which I can see a compelling argument for REST being inferior to SOAP except "degree of support from libraries written to support SOAP".

There's no WSDL or .thrift -equivalent for discovery, and no autogenerated client code which makes use harder. Getting up and running is slower because you have no way to validate that your messages are well-formed short of throwing them at the server and seeing what it sends back. What criteria are you seeing REST as better on?

Re: Who Cares about GET vs. POST? NoREST

#55
post #26

Earlier quoted context omitted.

I think that we're only a few years away from someone reinventing SOAP but with JSON playing the role of XML.

And a hip name, like Dove or Ivry.

I hope all the backends are written in JS and run in the browser.

Re: Who Cares about GET vs. POST? NoREST

#56
post #7

The criticism they start with is weird. They take this API call: OrderDTO Customer::GetOrder(int customerID, int orderID) And this HTTP call: GET /customer/33245/order/8769 And ask: > If we put the function name between the parameters themselves, then it leads to the question, what part of this URL is the endpoint? But the thing that is between the parameters is "order" not the function name "GetOrder". If you look a…

> advocating abandoning it completely in favor of RPC-over-HTTP It surprises me that the author didn't go one step further and ask us to return to SOAP :)

Other than XML Schema, and XML namespaces, what was wrong with SOAP? Serious question. I genuinely think it had big advantages over REST.

Re: Who Cares about GET vs. POST? NoREST

#57
post #54

Earlier quoted context omitted.

> REST is worse than SOAP or something like Thrift for discoverability How? > worse for ease of use How? > worse for practically every criterion you could think about. I can think of lots of criteria, but very few on which I can see a compelling argument for REST being inferior to SOAP except "degree of support from libraries written to support SOAP".

There's no WSDL or .thrift -equivalent for discovery, and no autogenerated client code which makes use harder. Getting up and running is slower because you have no way to validate that your messages are well-formed short of throwing them at the server and seeing what it sends back. What criteria are you seeing REST as better on?

HATEOAS provides both discovery and, when well-known content types are used, potentially much richer ready-to-use client code than the autogenerated host-language interfaces provided by SOAP and similar protocols.

Re: Who Cares about GET vs. POST? NoREST

#58
post #40

Earlier quoted context omitted.

> Whether REST is a style or a standard is irrelevant Yes it is relevant.People right on HN spend their time arguing over what is restful and what isn't ,because vague "semantics". with RPC,no argument.And to be frank, if you're not using HATEOAS , there is very little difference between a api with beautiful urls and a few headers and rpc. The original spec is brilliant yet way to vague to be useful. RPC isn't HTTP,w…

> People right on HN spend their time arguing over what is restful and what isn't ,because vague "semantics". The defined semantics of HTTP/1.1 methods ( REST is a style, but HTTP/1.1 is a standard) are not vague. > And to be frank, if you're not using HATEOAS , there is very little difference between a api with beautiful urls and a few headers and rpc. If you aren't using HATEOAS, you aren't using REST. That doesn't…

> If you aren't using HATEOAS, you aren't using REST.

Then almost no REST api i've seen out there the is a REST api,which is my point exactly.

If you're writing a spec almost nobody understands and almost nobody truly implements yet everybody think they implement, then you failed at writing that spec. Because I can guarantee you out there a only few people understand HATEOAS.

And that's the heart of the problem. The reason is easy. While the idea of using a few verbs, etags and content negotiation is easy, HATEOAS is hard,period.It's hard the person who implements the api ( because someone has to code all the logic representing these states, the links, ...) ,it's hard for the client: the client has to be smart, urls aren't hard coded but need to be fetched from somewhere , and the body of a response needs to be parsed to know in which state the resource is, the actions, the relationships between resources, or sometimes the links are in the headers... You're not just sending data but also metadatas (just like RPC) that are only relevant in the REST logic, not in the actual application logic ... you're basically writing a web bot every time you're writing a rest client... All that for what? elegance basically.

As your link says, most devs are just using RPC with beautiful urls to begin with and stamp "RESTfull" on that. Don't you think there is a real issue here? I do.

Re: Who Cares about GET vs. POST? NoREST

#59
post #33

It would have been nice if he proposed something innovative moving forward, but this is a step back to RPC-structured APIs. After reading this though, I had to check to make sure it wasn't April 1st.

Gaining experience in technology is absolutely exhausting. Everyday there are posts, "New Shiny X!" and then six months later "Introducing No-X". Then a year later "New Shiny Y! Like X but without sesame seeds on the buns!"

This is one of my biggest problems with the software industry. It isn't just the posts, but the tooling / utilities / frameworks / languages as well. If you are smart enough to improve something, there is no fame in contributing to the open source project, some people would rather just re-write their own and attempt to force it down everyones throat.

Re: Who Cares about GET vs. POST? NoREST

#60
What an incredibly clueless post. I thought we’d left that level of misunderstanding behind us a few years ago.

There is no such thing as a RESTful URL. Characters in URLs don’t matter.

GET and POST have different semantics. Ignoring the benefits of caching is just dumb.

The semantics of status codes and verbs are defined pretty clearly. You might have to read an actual spec.

A paragraph starting with “A core difference between REST and RESTful …” physically hurts.

I can’t believe I just wasted time actually commenting on this.

Post reply on HN