Earlier quoted context omitted.
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 o…
State-based vs Signal-based rendering
51–60 of 64 posts
Re: State-based vs Signal-based rendering
#52Earlier quoted context omitted.
There’s a difference, see https://www.builder.io/blog/signals-vs-observables
Thanks! But what's being described there as "observable" is something other than the Observer pattern that "observable" comes from, which is closer to what it calls "signals". https://en.wikipedia.org/wiki/Observer_pattern
See https://github.com/tc39/proposal-signals?tab=readme-ov-file#... for more on how signals differ. Mainly no manual bookkeeping and the signal is kind of like a handle, and it allows lazy/computed signals that reference other signals and do the change tracking
Re: State-based vs Signal-based rendering
#53One way I frame such issues in my mind is that it's about who has control (and how much) over what is rendered and when on the screen I carry in my pocket. To some extent it is now Signal when I use the app. One day it might be my State instead.
Re: State-based vs Signal-based rendering
#54Earlier quoted context omitted.
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 o…
Game engines do not own their main loop anymore either. A lot of host platforms are event based now, including ios, macos, android, web, and to a lesser extend windows. This means you tell the host ‘call this function every X milliseconds’. This also means you do not have full control of a main loop and you get event calls. It is moving more towards event based like in web:) it prevents lockups
That is, yes, I shouldn't have mentioned the "main" method. You don't even necessarily want to own the main loop, if you will. The logic that you do every iteration of the loop, though, is something you will almost certainly see in most games. I don't think I've seen many (any?) applications where you could identify the main loop logic. Is typically spread out over god knows how many locations in the code.
Re: State-based vs Signal-based rendering
#55knockout js is that you?
I was about to mention this too. Compare: "import a specific lightweight library and wire together as needed" vs "write the whole app in terms of a bloated framework". I've been out of the frontend game for a while, but what does react give you that knockout and maybe some url management logic do not? I guess components are supposed to standardize modularity, so you can easily import some random widget?
Re: State-based vs Signal-based rendering
#56This 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
#57Earlier quoted context omitted.
I’m confused by your comment. Signals do reduce manual render management. By default, usestate causes unnecessary rerenders which signals avoid (all automatically).
It's not automatic though. Theres function calls() and you must createSignal for every derived value. When you ignore the performance aspect, React has the objectively least amount of boilerplate for reactivity. The question, that I genuinely don't know the answer to, is a) whether the performance improvement is worth it, and b) whether that's still the case after the compiler.
Re: State-based vs Signal-based rendering
#58Earlier quoted context omitted.
Original FRP was "behaviours" (continuous time-varying values) and "events" (discrete events, which map to current signals).
Yes, you're right. I think I read some later FRP papers that used the term "signal" instead of "behavior", and I thought that was what you were talking about. FRP "events" are kind of like the kind of signals being discussed here, but there are still big differences.
I don't think the differences are that significant, JS signals are basically `latch(frp-event-stream)`, eg. FRP events yield edge-triggered systems and JS signals yield level-triggered systems, and latches transform edge-triggered to level triggered.
I understand why people can see JS signals as FRP behaviours though, as both have defined values at all times t, but the evaluation model is more like FRP events (push-based reactivity), so I think edge vs. level triggered is the real difference, and these are interconvertible without loss of information.
IIRC, the FRP literature calls both of them "signals" as a general category, just two different types.
Re: State-based vs Signal-based rendering
#59Earlier quoted context omitted.
It's not automatic though. Theres function calls() and you must createSignal for every derived value. When you ignore the performance aspect, React has the objectively least amount of boilerplate for reactivity. The question, that I genuinely don't know the answer to, is a) whether the performance improvement is worth it, and b) whether that's still the case after the compiler.
have you tried svelte 3/4?
let doubled = $derived(count * 2);
React: const doubled = count * 2Re: State-based vs Signal-based rendering
#60I 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…
Immutable does not mean you have to copy the whole structure. You can store only the changes. This is how immutable data structures work in functional languages such as Haskell.
Also, for nested data structures you need to either do path copying, or use "modification boxes" [1].
[1] https://en.wikipedia.org/wiki/Persistent_data_structure#Tech...