Live data from Hacker News

What Are Signals?

signia.tldraw.dev

21–30 of 63 posts

Re: What Are Signals?

#22

I don't really understand why people like signals again. I used a signals-like reactive programming model in VueJS a while ago and hated that you could never be sure exactly where things were being changed. Thankfully it seems that the React creators and maintainers are not hopping on the signals train and are instead adamant about unidirectional dataflow with explicit mapping of state to UI, which, as has been the r…

Elm managed to move away from signals back in 2016 (controversial at the time, but IMO a great move).

https://elm-lang.org/news/farewell-to-frp

Re: What Are Signals?

#23

I don't really understand why people like signals again. I used a signals-like reactive programming model in VueJS a while ago and hated that you could never be sure exactly where things were being changed. Thankfully it seems that the React creators and maintainers are not hopping on the signals train and are instead adamant about unidirectional dataflow with explicit mapping of state to UI, which, as has been the r…

Because it's nicer. The mental model of reading the functions using signals is; it's all about initialize|constructor|new function. And then those off-jsx stuff starts to make sense since you won't re-initialize those things. They need to exist somewhere in particular execution model. In Solidjs, it's effects (compiled from jsx where signals are read). I think those who are familiar with static type languages, natura…

When you have a big app, it becomes a spaghetti mess, and I speak from personal experience having to untangle that spaghetti.

Re: What Are Signals?

#24
post #2

At first I thought this was talking about Unix signals Then I thought for a moment it was talking about a "signal" in the information theoretical sense All I came away with was that they've invented a new name for event driven architectures and/or data flow programming. I know naming is hard but we need to stop overloading terms.

Signal isn't overloaded. It's use here is the same as it's use elsewhere. It just requires contextual information to know what it means. A Qt programmer might think of signals and slots, a UNIX programmer might think of UNIX signals, etc. Jargon sure. Overloaded? I don't think so. Only thing here that bothers me is how vague the title is.

Re: What Are Signals?

#25
post #3

It’s kinda funny to see “signals” coming round into fashion or popular discussion in front-end tech Twitter. Mobx is a signals state management library has been around for 7 years. Notion used signals internally for state management and often when engineers joined they’d ask why we use signals over Redux, can we switch to Redux because it’s more modern, etc. Now it’s 4 years later and for some reason this pattern is…

There is a schism between "JS influencer Twitter devs" and "Building actual apps devs"

I have stopped taking seriously people that rely on novelty to sell you their next training.

Re: What Are Signals?

#26
post #2

At first I thought this was talking about Unix signals Then I thought for a moment it was talking about a "signal" in the information theoretical sense All I came away with was that they've invented a new name for event driven architectures and/or data flow programming. I know naming is hard but we need to stop overloading terms.

The terminology of signals (and slots) has been used in Qt [0] since the 1990s I believe.

Still, it is unfortunate that the article begins with “Let's start with an extremely broad definition” (of signals), then continues with what sounds like signals in general, mentioning React only as an example, but then turns out wanting to only talk about signals in the particular reactive UI sense common in web development, without properly introducing that narrowing of focus.

I guess that focus can be expected from a blog on a site about a TypeScript signals library, but from the way the first few paragraphs are written, it’s certainly confusing when reading the article without further context, coming from HN.

[0] https://en.wikipedia.org/wiki/Signals_and_slots

Re: What Are Signals?

#27
signals represent continuous time varying quantities, like an electrical voltage, an audio signal or the current mouse coordinates. streams (event streams) represent a sequence of discrete events, like key presses or network packets or financial transactions.

the key difference is in backpressure strategy: signals are canonically lazy, they don’t compute or do work until sampled, and only the latest value is relevant (nobody cares where the mouse was a moment ago when nobody was looking). streams are eager, you can’t skip a keyboard event or a financial transaction, even if the pipes are backed up – instead you have to tell upstream to slow down so you can catch up. The benefit of event streams is the guarantee that you'll see every event, which means streams are suitable for driving sequences of side effects (keyboard event -> network request -> database transaction).

signals are a good fit for rendering because you only want to render at up to say 60fps (even if the mouse updates faster, which it does). and you only want to render what’s onscreen, and only when the tab is focused. rendering (say dom effects) is indeed effectful but not in the discrete way; the dom is a resource, it has a mount/unmount object lifecycle, and due to this symmetry it is a good fit for rendering whereas isolated effects (without a corresponding undo operation) are a terrible fit for signals because backpressure will drop events and corrupt the system state.

You can use streams for rendering too, but it's dis-optimal, and potentially by a lot. If your app chokes on a burst of events, you want to skip ahead and render the final state without bothering to render all the intermediate historical states. Signal laziness is what enables this "work skipping"; a stream would have to process each individual event in sequence.

I have no idea if JS projects get the backpressure right, can anyone confirm?

Re: What Are Signals?

#28
post #26
post #2

At first I thought this was talking about Unix signals Then I thought for a moment it was talking about a "signal" in the information theoretical sense All I came away with was that they've invented a new name for event driven architectures and/or data flow programming. I know naming is hard but we need to stop overloading terms.

The terminology of signals (and slots) has been used in Qt [0] since the 1990s I believe. Still, it is unfortunate that the article begins with “Let's start with an extremely broad definition” (of signals), then continues with what sounds like signals in general, mentioning React only as an example, but then turns out wanting to only talk about signals in the particular reactive UI sense common in web development, wi…

> The terminology of signals (and slots) has been used in Qt [0] since the 1990s I believe.

Was confusing then and is still confusing now.

Re: What Are Signals?

#29
post #3

It’s kinda funny to see “signals” coming round into fashion or popular discussion in front-end tech Twitter. Mobx is a signals state management library has been around for 7 years. Notion used signals internally for state management and often when engineers joined they’d ask why we use signals over Redux, can we switch to Redux because it’s more modern, etc. Now it’s 4 years later and for some reason this pattern is…

Similarly Angular 1 allowed component oriented development far before react. But people seem to think React invented it.

The problem with angular 1 components (isolated scope directives) was simply that not many understood it as a best practice until far too late, and the framework allowed you to do all kinds of terrible designs like shared scope/multiple controllers per file, which was the more common way to develop. Also performance was poor.

Feel the same way about signals. Vue has been doing it for years (just not tied into render optimizations). I used a similar model via angular 1 back in 2014 even, via watch chains. Much less performant though. Can also do it via redux by defining a special third arg which defines state depenencies (which we do here).

Nothing really novel about a tree-like series of derived states. Interesting that social media is ablaze like its something new

Re: What Are Signals?

#30
post #5
post #3

It’s kinda funny to see “signals” coming round into fashion or popular discussion in front-end tech Twitter. Mobx is a signals state management library has been around for 7 years. Notion used signals internally for state management and often when engineers joined they’d ask why we use signals over Redux, can we switch to Redux because it’s more modern, etc. Now it’s 4 years later and for some reason this pattern is…

Same here, I have been spreading mobx everywhere I have gone. There's usually some resistance but once people got used to automatic dependency tracking, they never go back. I've seen so many projects get bogged down in props hell, then gobs of context api and performance problems when too many things react at once. Mobx has been solving these problems for a long time now!

I recently started ripping Mobx out of my app. Mobx solved exactly 1 problem for me, which was passing data horizontally (to siblings/cousins) and even to non-React components.

But now `useSyncExternalStore` solves that. No context needed. Can read and write state anywhere, even outside components. No "observe" or "track" shenanigans. Efficient updates (can listen to a subsection of the tree).

Post reply on HN