Kartik Agaram
Ivan Reese
Chris G
08/13/2023, 6:01 PMMaikel
08/13/2023, 6:07 PMKartik Agaram
Mariano Guerra
Kartik Agaram
Mariano Guerra
Mariano Guerra
Mariano Guerra
Kartik Agaram
Ivan Reese
Kartik Agaram
Mariano Guerra
Mariano Guerra
Jason Morris
08/13/2023, 8:21 PMJason Morris
08/13/2023, 8:32 PMJason Morris
08/13/2023, 8:34 PMJack Rusher
08/14/2023, 6:06 AMKartik Agaram
wtaysom
08/14/2023, 7:20 AMKonrad Hinsen
08/14/2023, 9:47 AMJack Rusher
08/14/2023, 10:52 AMfuture
to start a second task:
(def image (atom nil))
(defn plot [thing]
(future
(reset! image (if-let [filename (plot-thing-return-filename-or-nil thing)]
(load-image filename)
error-image)))) ; presumably a sad computer face :(
(defn application-loop []
,,,) ; call plot when they push the button
Mattia Fregola
08/15/2023, 1:54 AMChristopher Shank
08/15/2023, 6:29 AMTypically, each event handler starts with a basic sequence of actions that will be executed in response to an event. And because an item may respond to an event in different ways, depending on the context in which it is used, conditional statements are added to determine the context in which the event has occurred and therefore which actions to execute.
- Constructing User Interfaces with Statecharts (1999)It seems like the LOVE game engine is is nudging you to reason about the behavior of this UI directly in its event listeners (e.g. `load`/`update`/`render`). Specifically, I don't fully understand why it's necessary to check whether the file exists on every frame (i.e.
update
) and defensively guard against it? Feels like complexity is creeping in from that.
While a statechart is not going to solve all of your problems, I do think there are compelling reasons it could be useful at the very least to reason through the behavior of this UI.
machine Rplot {
on PLOT -> .querying do resetImage
initial state idle
state querying {
spawn R_query
from R_query {
on IMAGE_READY -> drawing do setImageFromFile
}
}
state drawing {
on RENDER do drawImage
}
}
This example is of a little language called StateML that I'm currently building out. It enables us reason about behavior higher up the ladder of abstraction and provide "named holes" to fill in implementations when we pull it into the host language latter on.
• The PLOT
event causes a transition no matter what state the UI is in.
• In the querying
state we defined that an R_query
activity is spawned. The lifetime of an activity is bound to the state it is spawned in and the statechart can react to events sent directly from that activity. The implementation of R_query
is left open, the only behaviorally important aspects are that it emits an event that tells us when the image file is ready and has logic to cancel/ignore the query if another PLOT happens. If you want to implement that with polling or some other method it's up to you.
• Once the query finishes we enter the drawing
state and draw the image on each frame.
• Even for this simple example there are cases that are not covered like if the image fails to generate or maybe takes too long what should be do. We can easily specify that additional behavior:
machine Rplot {
on PLOT -> .querying do resetImage
initial state idle
state querying {
spawn R_query
from R_query {
on IMAGE_READY -> drawing do setImageFromFile
on ERROR -> idle do displayError
}
after 30s -> idle do showTimeoutError
}
state drawing {
on RENDER do drawImage
}
}
guitarvydas
08/15/2023, 2:20 PMguitarvydas
08/15/2023, 2:25 PMguitarvydas
08/15/2023, 2:27 PMLu Wilson
08/20/2023, 6:30 AMI'm just curious to see examples of how others might organize the state machine in my doc to be easier to maintain.
By drawing lots of pictures (on paper, post-it notes, napkins, and sometimes tldraw). Here's the state machine we drew when we were building 'cursor chat':
Lu Wilson
08/20/2023, 6:32 AMLu Wilson
08/20/2023, 6:33 AMLu Wilson
08/20/2023, 6:35 AMKartik Agaram
Mattia Fregola
08/21/2023, 7:08 AMJason Morris
08/22/2023, 5:36 PMLu Wilson
08/22/2023, 5:39 PMKartik Agaram
Jason Morris
08/22/2023, 5:43 PMJason Morris
08/22/2023, 5:46 PMJason Morris
08/22/2023, 5:50 PMKartik Agaram
if your "states" have things like "duration", then they aren't really states, right? Or am I out to lunch.I tend to think of this as state machines with more or less accidental complexity. But maybe there's some canonical definition of a state machine that I'm missing..
Lu Wilson
08/22/2023, 5:54 PMKartik Agaram
Lu Wilson
08/22/2023, 5:58 PMLu Wilson
08/22/2023, 5:59 PMJason Morris
08/22/2023, 6:06 PMJason Morris
08/22/2023, 6:09 PMJason Morris
08/22/2023, 6:10 PMJason Morris
08/22/2023, 6:11 PMLu Wilson
08/22/2023, 6:14 PMIvan Reese
Kartik Agaram
The charts seem straightforward enough. And nested state machines are a thing.I've been seeing these state chart pictures all my life, and I've even tried reading the papers a few times. But I totally miss (or quickly forget) one key property. In a state chart enclosure is backstopping. If a state encounters an event it can't handle, it passes it up to the enclosing state. It seems obvious now that I write it out like that. And it's isomorphic with my previous understanding: that hierarchies are a way to extract common transitions and simplify the state diagram. But it still felt surprising. I think I have some theoretical knowledge but zero "fingertip feel" for state charts based on personal experience. Which makes all my opinions on it suspect..
Kartik Agaram
Jack Rusher
08/23/2023, 7:53 AMJack Rusher
08/23/2023, 3:32 PMKonrad Hinsen
08/24/2023, 6:23 AMguitarvydas
08/24/2023, 8:31 AMKartik Agaram
Lu Wilson
08/27/2023, 11:19 AMguitarvydas
08/27/2023, 1:18 PMLu Wilson
08/27/2023, 3:34 PMJack Rusher
08/28/2023, 7:55 AMguitarvydas
08/28/2023, 10:53 PMKartik Agaram
Konrad Hinsen
08/29/2023, 5:18 AMguitarvydas
08/29/2023, 12:57 PMKartik Agaram
Async-based senders don't wait for a result by default, and sometimes - but only sometimes - need to bother with sync'ing later.This seems completely at odds with my experience. The number of times in my life that I've made an async call truly fire-and-forget is at most 2. With a generous margin for forgetfulness. Invariably I want to check for errors. At best there is syntax to hide the error checking -- but it does that for sync calls as well. So I fail to see what the fuss is about. So far, sync vs async seems like an implementation detail. I don't think calling things epicycles or tired or fallacious or vehement is very persuasive by itself. At best you can claim, "look, here's an alternative prognosis for these symptoms that I'm working to falsify." And tell a story about how that might be the case. So far I haven't seen either enough evidence or a compelling alternative narrative.
Mattia Fregola
09/06/2023, 6:35 PMJ. Ryan Stinnett
09/06/2023, 11:23 PMLu Wilson
09/06/2023, 11:35 PMKonrad Hinsen
09/07/2023, 4:49 AMHTTP was design[ed] as a distributed realization of the Objective C (originally Smalltalk) message passing infrastructure [...]
Uniform Resource Locator is just the result of squeezing the term object reference through the IETF standardization process.
Jack Rusher
11/10/2023, 9:50 AMMattia Fregola
11/16/2023, 11:12 PMIvan Reese
Mattia Fregola
11/16/2023, 11:28 PMLu Wilson
11/17/2023, 7:28 AM