Live data from Hacker News

State-based vs Signal-based rendering

jovidecroock.com

31–40 of 64 posts

Re: State-based vs Signal-based rendering

#31
post #18
post #11

> Traditional state management like React hooks Oh boy. The youth of the author is really visible.

Calling hooks "traditional" in relation to signals seems fine, lest that word be relegated in time to whatever you in particular care about at this juncture. I'm sure some 80 year olds before us thought the same of us using that term.

First-class signals came from functional reactive programming back in 1997. Even JS implementations of signals existed before React's hooks.

Re: State-based vs Signal-based rendering

#32
It's hilarious that the Observable pattern that MVC and Qt are organized around has become "a game-changer for large applications where context is used to distribute state across many components" this year. MVC is maybe 50 years old now?

Re: State-based vs Signal-based rendering

#33
post #18

Earlier quoted context omitted.

Calling hooks "traditional" in relation to signals seems fine, lest that word be relegated in time to whatever you in particular care about at this juncture. I'm sure some 80 year olds before us thought the same of us using that term.

First-class signals came from functional reactive programming back in 1997. Even JS implementations of signals existed before React's hooks.

These "signals" don't seem like FRP signals (which are time-varying values, like a "signal" to an EE but not limited to real numbers) but more like Qt signals or MVC "model has updated" notifications.

Re: State-based vs Signal-based rendering

#35
post #22

It remains a bit of a mystery to me that applications seem to grow further and further from traditional game techniques. Both in how state is propagated through the application, and in how it is represented. Like, I understand why people aren't going full 3d game simulation style for applications. But I don't understand why things are as divergent as they are? Is this just my off perspective?

Can you expand a bit on what you mean? To me (extremely amateur game programmer), that's what, event buses? more explicit state machines?

Just general code organization is all I really mean. Typically an explicit main loop where you go through all of the stuff that the game cares about. With the proliferation of frontend frameworks, you often don't even have an analogue of a main method, anymore.

I have similar questions on asset management. But I think that one makes a bit more sense, though? Game studios often have people that are explicitly owners of some of the media. And that media is not, necessarily, directly annotated by the developer. Instead, the media will be consumed as part of the build step with an edit cycle that is removed from the developer's workflow.

Re: State-based vs Signal-based rendering

#36

This article is completely backwards. We do not want to manually manage what-gets-refreshed-when. The whole point of React was to react to state changes automatically.

Yeah, I'm interested to learn more about signals, but the article seems to miss the whole point of brute-force state updates -- less cognitive complexity.

Re: State-based vs Signal-based rendering

#37

I don't like the style of code in the article, with weird functions like "useState" and "useSignal". Looks ugly to me. Also, it seems that with signals you must use immutable values only. Imagine if you have, let's say, a text document model, and you need to create a new copy every time the user types a letter. That's not going to work fast. And there will be no granular updates, because the signal only tracks the va…

  Vue can be used without Node.
You lose a lot though! You don't get minification and tree shaking, single file components, or hot module reloading. In practice, HMR outweighs the cost of setting up a Node/Deno/Bun environment.

Re: State-based vs Signal-based rendering

#38
post #28

Relatedly, there is a stage-1 proposal to add first-class signals to Javascript: https://github.com/tc39/proposal-signals It's a collaboration between multiple library maintainers, attempting to standardize and unify their shared change-tracking approach.

Also some examples in the polyfill README [0]. Certainly looks interesting. I wonder some years down the future, if there will be no need for JS frameworks since a lot of what they offer will be integrated into JS itself. https://github.com/proposal-signals/signal-polyfill

Framework authors would love to not do the things they do if the platform provides great APIs and primitives.

Re: State-based vs Signal-based rendering

#39
post #18
post #11

> Traditional state management like React hooks Oh boy. The youth of the author is really visible.

Calling hooks "traditional" in relation to signals seems fine, lest that word be relegated in time to whatever you in particular care about at this juncture. I'm sure some 80 year olds before us thought the same of us using that term.

> Calling hooks "traditional" in relation to signals seems fine, lest that word be relegated in time to whatever you in particular care about at this juncture.

"Traditional" hooks are 6 years old. I think it's to early to call it traditional. Given that literally everyone else looked at this "tradition" and chose differently. Namely, signals.

Signals were popularized by SolidJS, but SolidJS's Ryan Carniato will keep telling you that what everyone calls signals now has its roots in libs like KnockoutJS from 2010. And everyone has been busy using signals for the past three years.

Given the amount of frameworks that implement signals today (including monsters like Angular), it's React who's not following tradition.

Re: State-based vs Signal-based rendering

#40

Preact signals are far superior to other state management patterns for react, but don't use a ContextProvider as shown is this article, pass the signals as props instead. e.g: function MyComponent({ disabled }: { disabled: Signal }) { // ... }

ContextProvider is for when you have some data that any random component might need, and you don’t want to clutter up the system by passing it through every component (this is called “prop drilling”). Or maybe you can’t pass it through some container component that you don’t control.

That consideration is orthogonal to what the useful data is. It could be a signal, or not. In other words, signals are not an alternative to context.

Post reply on HN