Skip to content

Instantly share code, notes, and snippets.

@dustingetz
Last active February 24, 2023 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustingetz/35f0e036283c49605f73917132931414 to your computer and use it in GitHub Desktop.
Save dustingetz/35f0e036283c49605f73917132931414 to your computer and use it in GitHub Desktop.

Proof of client/server transfer — Electric Clojure

Electric Clojure lets you code frontend/backend expressions that compose across the client/server boundary, due to compiler-managed network powered by DAGs. #Clojure

20230131.hello.photon.tranasfer.2.edited.mp4
  • p/defn defines a function that follows all the same laws as regular Clojure functions, but it’s actually a macro that compiles the function body into a DAG (Directed Acyclic Graph).
  • The DAG forms an event propagation network, resulting in reactive rendering like React.js. (No React.js on the page; fine-grained direct DOM effects are scheduled by https://github.com/leonoel/missionary, a functional effect and streaming system for Clojure/Script)
  • p/client and p/server mark streaming client/server transfer points in the DAG.
  • If the frontend backend is reactive, and the backend is reactive, inserting a small delay for a websocket hop has no impedance with the already async computation model. And your database queries are already heavier than a websocket hop.
  • For a deeper explanation, see UIs are streaming DAGs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment