DEV Community

Marcin
Marcin

Posted on • Originally published at marcin.codes on

What the fuss is about RPC

https://dev.to/karankumarshreds/go-rpc-implementation-4731https://dev.to/karankumarshreds/go-rpc-implementation-4731

RPC ( R emote P rocedure C all) — is a protocol to call servers and invoke some defined code on them. In comparison to REST or GraphQL RPC requests don’t need to return anything. RPC is oriented toward invoking arbitrary logic on the server. Instead of sending and receiving resources like in REST. On top of that, you can use it for this also.

What are the benefits of RPC?

  • Granularity

  • Independent

  • Batching

Let’s stop here and expand on these concepts:

Granularity — You can use these commands separately even if they share a common code or do almost the same. In REST we write logic around resources. It needs to be unified for all use cases but not all are the same.

Independent — command acts on their own.

Batching — Helps with sending commands in one network request. This can help avoid the waterfall requests problem.

Why is RPC brought now?

Some time ago Ryan Carniato introduced Solid Start on Vite Conf. He introduced server$ function. Using it you can turn any function async function into an RPC function that is executed on the server. This is huge!

Imagine building a client component. Next to it function that will be executed on the server. Then call that function inside of this client-side component and get results.

RPC also was introduced in Qwik. It can do the same as what is done in Solid but it goes even further. It enables us to make RPC from the closures function and derive closure variables.

https://twitter.com/mhevery/status/1630413469139996672https://twitter.com/mhevery/status/1630413469139996672

These solutions are great but they are coupled with their frameworks.

Bling enters the chat

As we can read in the repo. Bling is a “framework agnostic transpilation utilities for client/server RPCs, env isolation, islands, module splitting, and more.” It brings function colocation to every framework and open-up possibilities for island architecture.

What is Island Architecture?

Imagine your website as an ocean. You are sailing through it and only a certain part of it is interactive. Like comments section or like/dislike button. The interactive parts of a website are called islands.

Photo by Denys Nevozhai on UnsplashPhoto by Denys Nevozhai on https://unsplash.com

Credits

I want to give credit to the people that were involved in creating or shaping it.

About RPC I read in Solid Start docs and stumbled upon Qwik's showcase from Steve, something like this one. Then I learn that Ryan Carniato introduced a solid start on vite conf. The latest library Bling is inspired by all the previous works of Solid and Qwik.

I first heard about islands' architecture when Astro came out. They wrote about that in their docs. They mention Katie Sylor-Miller and Jason Miller's post.

Further reading

I strongly recommend reading Solid Start’s docs and Qwik docs. There are a lot of ideas and fresh looks at building apps. Not only connected with RPC or Islands Architecture. Also, take a look at Tanner Linsley Bling and join his discord server to be up to date.

Top comments (0)