Build a gRPC-style RPC framework (14 scenes)
Scene 01 · Calling a function on another machine
A remote call is dressed up to look like a local one — but unlike a local call it can fail after the server already did the work, so the caller can't tell if it happened.
Scene 01
Calling a function on another machine
Diagram
LEFT is one process: the call `greet("Ada")` and its return ride a single in-memory arrow — instant, all-or-nothing. RIGHT is the same call as an RPC: a client box sends a request across the wire to a server box, the server runs the body and computes "Hello Ada", and a reply travels back. The slider cuts the wire at a chosen moment; the strip along the bottom names the four ways a remote call leaks, with only 'partial failure' lit this scene. RPC: dressing a network round-trip up to look like a local call. Stub: the auto-generated client-side shim that makes that remote call look local.
local: one arrow, instant, all-or-nothing
Start with something you already trust. When your code calls a function like greet("Ada"), the call and the answer happen in one place, in memory — instantly, and all-or-nothing: it either ran and gave you "Hello Ada", or it didn't run at all. Now put the function on ANOTHER machine. Your code still writes greet("Ada"), but the framework quietly turns that line into a network round-trip: a *client* sends a request over the wire, a *server* runs the function body and computes "Hello Ada", and a reply comes back. That trick — making a call to another machine LOOK like an ordinary local function call — is called a **Remote Procedure Call (RPC)**: an RPC is a useful lie, a network round-trip dressed up as a function call. The piece doing the dressing-up is the **stub**: the auto-generated client-side shim that you call like a normal function, which packs your arguments, sends them, and unpacks the reply — so your code never sees the network. Watch the local call first, then the same call as an RPC. Linger on the wire: that gap between request and reply is the whole story.
Not sure what to ask? Tap a question — the staff engineer answers in the chat panel.