11 ms·
IMO it’s two things. 1. REST positioned itself in opposition to RPC. The concept of RPC is a negative one in many engineers’ minds. 2. JSON-RPC isn’t that muc
by peterhunt 4y ago
IMO it’s two things.
1. REST positioned itself in opposition to RPC. The concept of RPC is a negative one in many engineers’ minds.
2. JSON-RPC isn’t that much better than passing your own JSON formatted messages over HTTP. So I don’t think it gets you too much incremental value these days.
With that said I love JSON-RPC and tend to reach for it pretty often for prototypes or greenfield projects.
- pshirshov 4y ago> REST positioned itself in opposition to RPC. Whatever some people say, REST is a form of an RPC. If someone wants to object, they should think again and again and again.
- w-j-w 4y ago[dead]
- nsonha 4y agosaid who? the historical context is that REST comes after SOAP, a very clunky implementation of RPC, and positioned itself as different. It got popular because of its ease of debugging. Conceptually there is another key difference that is REST revolving around standard HTTP verbs and encourages CRUD like APIs while RPC encourages APIs more like a non networked APIs
- pshirshov 4y ago> said who Just think about it. For example, try to build isomorphism between REST and any RPC you want.
- deleted 4y ago[deleted]
- nsonha 4y agoWhat the hell is isomorphism, I'm a dum dum
- nabla9 4y agoYou are just trying to figure terminology and usage out on the fly by guessing. You should be learning, not arguing.
- theamk 4y agoI don't think it's a very good argument, in CS, you can build isomorphism between many things, especially when both terms are vaguely defined.
- nabla9 4y agoNo, it's not. You are making stuff up on the fly. RPC does not mean "Transferring bytes between computers across networks using some protocol." RPC = Remote Procedural Call. REST = Representational State Transfer. REST is closer to file transfer than RPC.
- pshirshov 4y agoYes it is. It's a semiformal weak-typed RPC.
- naasking 4y agoRPC does not make idempotency guarantees, REST does. Ergo REST is not RPC.
- pshirshov 4y ago> RPC does not make idempotency guarantees Not true. "RPC" is just a generic name and there are multiple approaches and implementations which may provide you some guarantees, in specific environments such guarantees may be strong. > REST does How can I enforce or trust any REST "guarantees"?
- LudwigNagasena 4y agoI don't know what REST is "really" supposed to mean [1], but every time I saw it used, it basically meant RPC with JSON over HTTP. I have just googled a random service that self-describes its API as REST [2]. I would be glad if someone could pinpoint me at the exact differences that make it "closer to file transfer than RPC". [1] I guess in its original long gone meaning it's something closer to what 90s web looked like, but no one uses it in that sense. [2] https://developers.google.com/fit/rest https://developers.google.com/fit/rest
- theamk 4y agoHere is an example: https://developers.google.com/fit/rest/v1/datasets#get_a_dataset https://developers.google.com/fit/rest/v1/datasets#get_a_dat... It says: "To get a dataset, do HTTP GET to this URL. The result is a JSON document". Notably, this does not _look_ like RPC call -- there is no "getData" anywhere, no {"status": "ok"} field. Instead, this is pretty identical to how you would access a static directory with weirdly-named files. (If you never worked with "static directory with weirly-named files" API, here is an example: ftp://ftp.swpc.noaa.gov/pub/forecasts/45DF/ . To fetch data, you access file named "{MM}{DD}45DF.txt" (via FTP, no less!), get the document and parse. The REST is a modern equivalent of this.) NotablyThis does not sound like a "getData()" function
- kybernetikos 4y agoI think this is confusing different levels of abstraction. It's certainly true that more or less any system can be turned into a sequence of 'procedure calls' with appropriate arguments and return values. You can make the equivalent argument that OO is just the same as structured programming, or that functional programming is just a form of assembly language. There's a sense in which it's correct (i.e. that it's possible to implement one with the other), but it's definitely not the right way to think about it. REST is about working with state objects that live on other servers. RPC is about getting other servers to do actions. They're different ways of thinking and coding, despite the fact that yes, you can wrap an action up in some state, or that most actions will be modifying remote state.
- itake 4y agoREST is an RPC?
- peterhunt 4y agoNot in the eyes of its creator https://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven https://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypert...
- LudwigNagasena 4y agoIs there a single example of API that fits that definition of REST though?
- empthought 4y agoHATEOAS is the search term you want to use. “Hypermedia as the engine of application state.” PayPal and GitHub APIs tend to work this way. They return a pile of hyperlinks.
- LudwigNagasena 4y agoIf by "tend to work that way" you mean that they satisfy around 20% of the requirements in the post by Roy T. Fielding as opposed to other services that satisfy only 10%...
- empthought 4y agoI don't think you are familiar with the GitHub REST API; none of Fielding's points apply to it.
- LudwigNagasena 4y agoI honestly don’t know how someone can design a truly HATEOAS API without breaking everyone’s expectations and making it a chore for people to deal with it. If stuffing a bunch of links into your JSON response is what truly transforms your RPC into REST (I don’t see what else makes GitHub API so different from other APIs), then I don’t even know what’s the point of that. And surely it is only superficially similar to the non-API REST, ie how simple websites usually work.