Avoid Using Sockets — Remote Procedure Calls and How to Use gRPC for Your Program’s Communication

Tiago Antunes
The Startup
Published in
7 min readAug 28, 2020

--

Illustrative image of a frustrated man looking at the computer with his hands on his forehead
Photo by Sebastian Herrmann on Unsplash — Difficult and annoying things make us frustrated, why not simplify them?

As we all know, it’s common to use sockets to create a communication channel between 2 programs that need to communicate over the internet. When doing so, our programs end up looking messy, with a lot of repetitive code to fix the common known problems and isn’t very pleasing to write.

Today I am telling you about RPC, a technology that has emerged lately and has one simple objective: to simplify the communication problem in programming.

Now if you have never worked with sockets you might be wondering “Wow what’s so hard about programming with sockets anyway?”. For that, let me give you a few examples:

  • Your programs need to explicitly handle communications for sockets to be deployed. This includes handling all the errors that might happen (for example retransmission, in case a message gets lost) and it’s not only complex but also very, very tiring
  • Your program will probably be interacting with other ones and this means it will have to marshal/unmarshal the data that will be sent as the systems participating might be heterogeneous (that is, they have different configurations — take a look at the simple example of endianness)

--

--

Tiago Antunes
The Startup

Computer Engineering student at Tsinghua University, Beijing | High-Performance Computing