I want to build the backend of an as-bidirectional...
# thinking-together
j
I want to build the backend of an as-bidirectional-as-possible spreadsheet/dataflow, does anyone have any favorite techniques? I’d like to prefer a dataflow style solution over a constraint solver. I’ve been reading up on why this problem feels hard and its similarity to the “view update problem” in databases, I’m curious if there’s a widely accepted solution that I’m missing.
i
[moved from top level, original message by @Alessandro Warth] I get that you're not looking for a constraints-based solution, but maybe you'll find this interesting anyway: https://github.com/harc/constraint-based-spreadsheet
j
Thanks @Alessandro Warth, would you mind sharing any thoughts on how the project went with the constraint approach? I’m thinking right now about leaning on lenses and some semantics discussed in this slideshow “Weird World of Bi-Directional Programming” from Benjamin Pierce. Was there a particular reason you chose a constraint solver? https://www.cis.upenn.edu/~bcpierce/papers/lenses-etapsslides.pdf
👀 1
d
I've been enamored with the Propagator Model as a solution to this problem. The idea is cells don't just store values, but more broadly they store information about what the value could be (such as a set of potential values), and propagators are like functions that react to changes in any number of connected cells, do computation, and then updated dependent cells continuously by* 'merging' in information (like finding the intersection of a set to get closer to a solution). It's a bit abstract, but these networks can be used as general purpose constraint solvers/computers by reacting to changes to cells and propagating updates to converge on a solution/steady state (they can be structured so they always converge). Bonus is nodes are 'actors' in the sense they are autonomous, async, and thus can be distributed/run in paralle. Sussman and Radul have a paper in it- this is the best intro ive seen (

https://www.youtube.com/watch?v=HB5TrK7A4pI

), and there are some implementations of it in Haskel for example by this guy
1
☝️ 2
Here's an visual: You can see how by wiring up an equation in both directions you can solve any variable given the other one*.
Lastly to add- this is not widely accepted- probably far from it. Just particularly interesting. Hope thats useful
d
Related, there's a great book on constraint theory by Friedman and Phan that digs into this kind of thing
👀 3
d
@Don Abrams really cool- just got a copy, curious to peruse
a
@Dennis Hansen if you're into scheme and p2p networking at all there's this interesting experimental propagator implementation built using Spritely Goblins: https://gitlab.com/spritely/brainy
🤯 1
w
Hello, and welcome to one of my favorite topics. I'm so glad to hear the Propagator Model mentioned. One thing I've learned in spending... oh my... a decade plus on the topic is that you must integrate invalid states and a view model from the start. Then soon enough, you'll really want versioning. Consider the simplest thing in a spreadsheet: • Set
A1 = 24.0
. • Set
A2 = A1 * 9 / 5 + 32
. • Come back to edit A1. Type "x". What should happen to A2? For a usual spreadsheet, the answer is nothing. When active, a cell's state shouldn't propagate, so make that part of the model in the first place. • Hit enter. We expect A2 to go funny in some way, ideally a way that points back to A1 as the source of the type error. An advantage of something like the propagator model is that you can wire your network as the basic level and then independently experiment with the semantics of error propagation. What about versioning? Versioning is useful for collaboration, yes. And undo is essential for any non-trivial model that you can mess up. But a real potential is realized in having the system make a bunch of version of things and then combine them. For instance, make a bunch of copies of A1 and A2. Vary A1 and chart how it affects A2. So instead of having separate looping constructs, just allow for clones/copies of the parts of the model. And if you make time first-class, instead of distinguishing between a clone and a copy, you can choose to either modify the original before or after copies were made to get a similar effect. An advantage is that you now have a well-defined semantics for conflicts when an embellishment of a clone is incompatible with a change to the original. You can pinpoint: this operation no longer works.
🤯 2
❤️ 2
💯 2
👍 2
j
Propagator model seems really interesting, thanks @Dennis Hansen @Don Abrams @avon @wtaysom! I’ll update when further questions come up.
❤️ 3
d
Just wanted to pop this in here for posterity! Made a propagator network simulator on top of tldraw https://futureofcoding.slack.com/archives/CCL5VVBAN/p1716413598853019