Skip to content

Instantly share code, notes, and snippets.

@jamesmunns
Last active January 16, 2024 12:29
Show Gist options
  • Save jamesmunns/2da0114782a93989d7c721b9f76730f8 to your computer and use it in GitHub Desktop.
Save jamesmunns/2da0114782a93989d7c721b9f76730f8 to your computer and use it in GitHub Desktop.

What if we specified “an RPC VM”?

Basically, lean into designing a basic language/repl/vm, with a plaintext and binary encoding format.

  • State is maintained as “session IDs”
    • Every request can be one of:
      • “CREATE SESSION” - creates a new session id, returned to client
      • “EPHEMERAL” - “oneshot” actions, do a single function call
      • “RESUME SESSION” - the provided input should be run in the context of the given session id, or should not run at all
    • These sessions (and bound values) can be serialized and stored in a DB, or kept in RAM, or either, or none
    • Server may choose to discard/evict sessions whenever they feel like it
  • Primitives are basically:
    • Binding values to IDs/names, within the session
    • Calling functions
      • Can pass values by IDs
      • Can bind return values to IDs
      • Do this forth/stack-machine style? But with stronger typing? like BoH in mnemos/forth3?
    • “recv/wait for input”
    • “send output”
      • Note: not everything gets “sent back” to the client. Only items that are actively sent.
  • Some notion of spawn/fork? so you could stream responses while doing other requests. Also join?
    • Structured concurrency server side in general?
    • This seems like a bad idea
  • Probably have some sort of “interpreter fuel” or “fuel rate” for rate limiting in CPU/network/ram time

Servers define the NOUNS and VERBS, clients define the FLOWS. Servers become libraries and vms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment