r/programming • u/fagnerbrack • Jun 13 '26
Signals, the push-pull based algorithm
https://willybrauner.com/journal/signal-the-push-pull-based-algorithm11
4
u/dashdanw Jun 13 '26
I know this is going to come off as a bit cruel, but what is this doing besides reinventing reactive programming yet again?
35
u/dacjames Jun 13 '26
The article doesn't claim to invent anything. It's an in depth explanation of a widely used mechanism for implementing reactivity.
It does say that in the opening paragraph...
-19
u/dashdanw Jun 13 '26
I guess I’m just struggling to really see how this enhances or changes the existing paradigm.
24
u/QuineQuest Jun 13 '26
Again, it doesn't claim to.
I don't see how your post enhances the taste of Cola in any way.
-12
u/dashdanw Jun 13 '26
If I make a post about cola claiming a thing that I am detailing and conceptually implementing an extension of the concept of cola then yes, it should somehow impact your experience of cola.
14
u/QuineQuest Jun 13 '26
Where do they claim they're conceptually implementing an extension of the concept?
-3
u/dashdanw Jun 14 '26
Under the section labeled “Basic Signal implementation”
11
u/QuineQuest Jun 14 '26
You mean where he said " I went through the exercise of implementing a very basic version"?
You're missing some basic reading comprehension.
-1
u/dashdanw Jun 14 '26
The idea of "signals" in this case, is the extension of the concept of reactive programming. I can't tell if you're being willfully ignorant here but either way I think you're arguing in bad faith.
5
u/QuineQuest Jun 15 '26
Signals is an implementation of reactive programming. It's not an extension of the concept.
6
u/fagnerbrack Jun 14 '26
Sometimes people might be hearing about reactivity in one context and this basically offers another context and more depth.
Sometimes just because we know something that doesn't mean everybody else knows the same thing as ourselves also
... And let's agree the animations are pretty sick 😆
4
u/mshm Jun 14 '26
Do you think when the Four wrote Design Patterns in 1994 they were "reinventing" object oriented programming yet again? The article literally starts with the fact that signals have been used for years (incidentally, the Observer pattern is described in the aforementioned '94 book). This is the existing paradigm. It's literally just an article teaching the concept in detail with examples.
1
u/StepIntoTheCylinder Jun 15 '26
It was never finished. The whole concept of a SPA was always being invented as we went along, and is still in flux. Some of the things people do with SPAs today is crazy. Perfecting the flow of data change is restrained by comparison.
0
2
u/backwrds Jun 14 '26
for (const fn of Array.from(subs)) fn(v)
why Array.from?
6
u/ProdigySim Jun 14 '26
Probably copying the subs list incase they mutate between invocations of the subscriptions?
3
u/Browhair3834 Jun 14 '26
Exactly
2
u/backwrds Jun 14 '26
Well... I was under the impression that `Set` iterators already handled that. It turns out I was totally wrong.
4
u/ProdigySim Jun 14 '26
Nice article, thanks for the writeup--Really clear code tour. Digging in to the internals for these really helps me understand how they work. Looks like a similar trick to React hooks--global state and synchronous code lets you make assumptions/guarantees to coordinate between the consumer and producer.
66
u/Ecksters Jun 13 '26
While signals interacting with each other doesn't seem particularly magical to me, it's libraries like MobX that automatically wrap primitives and vanilla objects in observable patterns using JS Proxy that always feel like magic to me, especially when they start intercepting and reacting to modifications to properties or mutations to arrays.