Skip to content

Instantly share code, notes, and snippets.

@dustingetz
dustingetz / electric-virtual-scroll-v2.md
Last active February 25, 2023 23:41
Electric virtual scroll over node_modules v2

virtual scroll over node_modules v2 — Electric Clojure

  • Direct filesystem reads from the view
  • Direct function composition in the style of PHP, despite network
  • No API, no client side database, no frontend state at all (except DOM), no frontend/backend.
  • Literally all accidental complexity GONE
  • 100% of server data sync is managed by Electric
  • Rows have arbitrary server local data access, here querying file metadata #clojure
  • Optimized and no scroll jank – DOM elements are fixed in place and reused

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).

List of Photon demos and content

Photon is a network-transparent Clojure/Script dialect for full-stack web application development. It uses macros to let you interweave client and server code in a single .CLJC file, so you can define a full-stack frontend/backend webapp all in one place. Photon is designed for stateful full-stack web applications with complex frontend/backend data sync requirements.

Newest demos:

Personal favorites:

(ns dustin.y2021.missionary_promise
(:require [hyperfiddle.rcf :as rcf :refer [tests % !]]
[missionary.core :as m]))
; We want to turn a promise-thing into a Task
; Leo: The problem with Promise and CompletableFuture is no cancellation
; What task do we want? Is the task listening to the promise? Or is the task the process backing the promise?
; Background: when you get a promise, there is a process in the background which eventually completes the promise.
; Do you want to await the result of an already running promise
; or do you want to run the process of the promise when the task is run?
@dustingetz
dustingetz / a.md
Last active October 4, 2022 15:47
HOWTO install `#uri` reader extension in Clojure/Script
@dustingetz
dustingetz / user.clj
Last active September 28, 2022 18:05
binding conveyance
(defmacro future
"Takes a body of expressions and yields a future object that will
invoke the body in another thread, and will cache the result and
return it on all subsequent calls to deref/@. If the computation has
not yet finished, calls to deref/@ will block, unless the variant of
deref with timeout is used. See also - realized?."
{:added "1.1"}
[& body] `(future-call (^{:once true} fn* [] ~@body)))
(defn future-call
@dustingetz
dustingetz / hfql.md
Last active September 22, 2022 14:00

Live-coding demo of #Hyperfiddle UI modeling language

  • forms, tables, hyperlinks, routing
  • queries on backend, rendering on frontend
  • dynamic query dependencies
  • WYSIWYG in-browser live editor

Strong composition – it's a functional expression! Compiler-managed network

Datomic database transaction browser coded in Photon, by nottmey

This fullstack web app is 239 LOC in a single file, coded with just fns in the straightforward/easy style of PHP. All client/server I/O is managed!

It took him 10 hours. Thank you Malte! #Clojure

20220529.Photon.Datomic.Viewer.-.Malte.Nottmeyer.mp4

10k dom elements with Photon

  • Plus free multiplayer of course
  • 25 LOC of which 48% are requires, CSS and whitespace. Count it!
20220823.10k.dom.elements.pixel.game.multiplayer.mp4
@dustingetz
dustingetz / a.md
Last active September 12, 2022 13:32
Photon demo: database branching (time travel)

Photon demo: database branching (time travel)

  • This demo uses DataScript's API for speculative transactions, not sure if can be done with sql read transactions.
  • DataScript is on the server; code is network-transparent.
  • 100 LOC for everything (table, query, popover, css, page)
20220910.branched.popover.staging.area.2.mp4