0
votes

Just to clarify what I mean by RESTful, it should satisfy the following constraints, taken from here:

  • Uniform Interface

  • Stateless

  • Cacheable

  • Client-Server

  • Layered System

  • Code on Demand

From my research, I believe that they aren't RESTful, primarily because :

  1. They do not use HTTP verbs.

  2. They do not use HTTP Response Codes.

  3. They does not follow principles of REST connectedness which is based on HATEOAS.

Refer this resource for more information about data above conclusions are based on.

Some resources like these seem to suggest these frameworks can be used/implemented as RESTful.

Please refer to resources you're basing your answer on. This question is intended to clear the misconception about the topic strongly citing official resources.

2

2 Answers

1
votes

Are RPC frameworks such as Apache Thrift or GRPC or any other RPC framework RESTful?

Taken in isolation: no.

The definitive reference on REST is Architectural Styles and the Design of Network-based Software Architectures. Roy Fielding describes the architectural constraints that were developed while working on the web standards (RFC 1945, RFC 2068, RFC 2616, later RFC 7230).

REST is intended for long-lived network-based applications that span multiple organizations (Fielding, 2008)

"The World Wide Web" would be an example of an application built using the REST architectural style.

HTTP methods and status-codes are not themselves a REST constraint. In a REST architecture, the client and server share semantics by exchanging messages, but those aren't required to be HTTP messages. You could replace HTTP with another protocol that conforms to the architectural style, and still have a REST architecture.

Some resources like these seem to suggest these frameworks can be used/implemented as RESTful.

People who understand REST to mean HTTP+JSON are going to reach conclusions that are inconsistent with the web architecture and Fielding's thesis.

In short - HTML does a lot of the heavy lifting in making the web architectural style successful. JSON, in contrast, does not include the semantics of a "link" or a "form" that can be used to communicate to the client which transitions are possible. You need some other semantics on top of JSON to allow the server to communicate to the client which application transitions are possible; either Web Linking or a hypermedia aware dialect of JSON.

As far as can tell, you could use Thrift to create an application that satisfies the REST architectural constraints. But my guess is that it wouldn't be a particularly satisfying experience: Thrift was developed because Facebook needed a system with properties that the Web architecture didn't satisfy.

REST is great for the web. Howver, the stack composed of REST, HTTP and JSON is not optimal for high performances required for internal data transfer. Indeed, the serialization and deserialization of these protocols and formats can be prejudicial for overall speed. -- Leo Schoukroun

URI, HTTP, HTML are easily repurposed, but that flexibility comes with costs. In settings where that flexibility doesn't provide value (for instance, because you are a single organization that controls deployment of the client and the server), then more efficient formats and protocols become more interesting.

It's similar to the trade off that we've made between HTML and JSON -- JSON isn't a useful hypermedia representation; but it's perfectly satisfactory for consumption by the code on demand that has been loaded by our hypermedia representation.

Horses for courses.

0
votes

REST is by definition not RPC, because the most significant distinction of REST is that it is resource oriented, which RPC is (typically) not.

Furthermore, one should refrain from trying to solve problems that are crying for RPC by inventing some "RPC over REST" solution - Programmers SE is full of these kind of questions.

In fact, such an approach would be upside down: One can implement a REST-based system by means of RPC, but the whole idea why one would want to use REST is on a completely different abstraction plane.

So I'd say the question is (sort of) a category mistake.