News for hackers. Stuff that matters.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by applfanboysbgon on Tuesday March 24, 2026 @07:13AM (#47500981)
I genuinely don't understand why this model is the norm. As a game developer working in my own engine, UI is unbelievably straight-forward: the game has state. The master Render() function draws all of the graphics according to the current state, called at framerate times per second. Nothing in Render() can change the state of the program. The program can be run headlessly with Render() pre-processed out completely. The mental model is so easy to work with. There is a sleep-management routine to save on CPU usage when idle, and dirty logic to avoid re-drawing static content constantly. I feel like the world would save 90% of its GUI development time if it didn't do whatever the fuck reactive UIs are doing.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by whstl on Tuesday March 24, 2026 @07:45AM (#47501257)
> The master Render() function draws all of the graphics according to the current state

What you are describing is exactly what GP complained about: "state as something distinct from both the UI and the data source".

React can be 100% stateless, functional, and have the state live somewhere else. You just need to apply the same limitations as your model: components should be simple and not store data in themselves.

This is why people came up with things like Flux/Redux/Reducers/Immutability, to handle this in a standardized way, but nothing is necessary.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by cluckindan on Tuesday March 24, 2026 @08:24AM (#47501613)
>components should be simple and not store data in themselves.

That is a ”controlled component” model which is bad for interactivity, especially text inputs.

If every keypress triggers a state change and rerender, the UI will be slow and things like focus management become complex issues.

Without a rerender, it must now use a reactive binding to update the field value.

If you don’t want to update state on every keypress, your component must be uncontrolled, store its state internally (in the DOM) and update it to a parent store e.g. when the user stops typing (debounced) or moves focus out of the field. These are not trivial things either, and as a result, components get more boilerplate to handle the UX complexity. And of course, there are now UX pitfalls.

Indeed, these are reasons why reactive patterns exist. Now, if they just managed to abstract away the tedium.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by Izkata on Tuesday March 24, 2026 @09:41AM (#47502478)
I don't know what people generally recommend now, but for a long time the best practices with organizing React components had them connected to the store midway down the tree or higher, which definitely would have contributed to the UI slowness since it would rerender everything below that on each update. Push the store access down as far into the leaves as possible and you won't get anything noticeable, even though it is still doing more work than just accessing the DOM state as needed.

Also, focus management isn't really a thing in React, the vdom diffing means DOM nodes are updated instead of replaced so focus isn't lost or changed unexpectedly. There used to be a demo on the React homepage showing this, since the idea was very new to most people at the time - everything popular before it was just rendering template fragments to replace nodes and did have this problem.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by cluckindan on Tuesday March 24, 2026 @11:23AM (#47504027)
Focus management is absolutely a thing in React if you plan to be ADA or WCAG compliant, even if it’s not needed for text inputs.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by codethief on Tuesday March 24, 2026 @09:29AM (#47502303)
> React can be 100% stateless, functional, and have the state live somewhere else. You just need to apply the same limitations as your model: components should be simple and not store data in themselves.

"just" is doing a lot of heavy lifting here. Where do you store "pure" GUI state (button state, is expandable expanded, …)? Do you really want to setup Redux for this? (And no, the DOM is not an option in non-trivial cases.)

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by Jenk on Tuesday March 24, 2026 @09:44AM (#47502511)
Might be naive, but this has always been a concern of the view-model for me. Every GUI change results in a VM change via event/command. The VM becomes gospel for UI state which means reducers are much simpler, and my actual model doesn't care if it is indeed a button, expando, radio button or whatever else.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by codethief on Wednesday March 25, 2026 @07:38AM (#47515991)
Isn't React pretty much a model-view-viewmodel architecture?
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by Jenk on Wednesday March 25, 2026 @08:28AM (#47516436)
Yes but it is easy to abuse/misuse IME, in that I think it requires one to maintain your own sense of discipline for the principle separation rather than the library/framework guide you into it. The threshold between UI and state management is comically easy to confuse.

Not dismissing it, mind, that inherent guidance is not something that is easy to achieve and I much prefer working with the likes of React than without.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by whstl on Tuesday March 24, 2026 @11:03AM (#47503708)
I'm not defending this model anywhere. I'm just stating that React can do what applfanboysbgon suggested: "As a game developer working in my own engine, UI is unbelievably straight-forward: [...]"
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by hliyan on Tuesday March 24, 2026 @07:17AM (#47501022)
That reminded me of another complexity: virtual DOM diff.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by croes on Tuesday March 24, 2026 @07:35AM (#47501174)
UI is mostly static. Rendering everything at framerate per second is a huge waste of time and energy.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by Lerc on Tuesday March 24, 2026 @07:54AM (#47501335)
This was the case back in the days of the Amiga and 68000 Macs. Rendering everything every frame was impossible, the only way to make it work at all was to draw only what was absolutely necessary to depict changes.

Then computers got faster, much much faster. It became possible to redraw the whole UI from state every frame without it being a significant cost.

At the same time retained user interfaces managed to become more and more costly to do just about anything. I don't think for any particular reason other than computers were fast and they didn't need to do much better.

I find it really odd that there are user interfaces that take longer to rearrange their items than it takes for the same CPU to RayTrace a scene covering the same amount of screen area.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by croes on Tuesday March 24, 2026 @08:16AM (#47501527)
Just because computer got much faster doesn’t mean it’s a good idea to make wasteful rerenderings of things that didn’t change.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by Lerc on Tuesday March 24, 2026 @08:23AM (#47501607)
No but calculation becoming more efficient than recall might not make it a good idea to make wasteful fetches.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by croes on Tuesday March 24, 2026 @08:37AM (#47501735)
Nothing id more effective than doing nothing.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by mpalmer on Tuesday March 24, 2026 @07:37AM (#47501191)
You genuinely don't understand why a web developer would never want to build immediate-mode UIs?

At the very least, I understand why your techniques help you...

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by applfanboysbgon on Tuesday March 24, 2026 @07:46AM (#47501264)
Indeed, I genuinely do not. Rather than passive-aggressively insulting my intelligence, why not explain it for me? As I understand it, React was an attempt to shoehorn "immediate-mode UI"[1] on top of retained-mode UI, so it seems like web developers do in fact want to build immediate-mode UIs, and in fact are constantly complaining about the nightmarish complexity of the status quo.

[1] I loathe this term, by the way. It's one of those terms that, I think, belong to a discipline of developers who love to obfuscate everything, even simple concepts, with unnecessarily opaque terminology until nobody can understand what the hell anyone is talking about anymore.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by never_inline on Tuesday March 24, 2026 @08:16AM (#47501528)
I am no web developer but whenever I built the UIs, re-rendering a page by doing some big DOM change through JS as always led to stutter. So maybe its just inefficient and can't be optimised.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by bryanrasmussen on Tuesday March 24, 2026 @08:02AM (#47501401)
>As I understand it, React was an attempt to shoehorn "immediate-mode UI"[1] on top of retained-mode UI

the problem is that the typical modern web page is considered as a combination of immediate-mode and retained-mode.

therefore, as it is wasteful to update all the page when only a few components on the page change, people want to only update parts of the page immediately when changes happen.

furthermore the typical modern web page only makes sense in the context of the modern web site, so some pages are almost everything on the page needs to update all the time, some pages are nothing here needs to update until the user does anything, some pages are nothing here needs to update at all, and other pages are just a couple components need to update all the time based on various things.

This context of what a web site is like is very much determined by the type of the site, where many e-commerce sites are affected by all sorts of data that occur outside of whatever page the user is on and need to update all sorts of different components on a page, many governmental sites are almost just static, with all sorts of variations in between.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by cluckindan on Tuesday March 24, 2026 @08:28AM (#47501661)
Which part of a web page is immediate mode, exactly?

Maybe <canvas> if you clear it on every frame.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by bryanrasmussen on Tuesday March 24, 2026 @12:54PM (#47505684)
I was just responding to the usage that the parent commenter had which was

>As I understand it, React was an attempt to shoehorn "immediate-mode UI"[1] on top of retained-mode UI

which I interpreted as the only possible meaning, in relation to React, being UI components that must rerender as close to immediately as possible vs. UI components that do not need immediate rerendering when the underlying data has changed.

I realize that is not a particularly correct use of the phrases, but then that is what happens when you use a concept from one type of development metaphorically in another type of development, memetic slippage as it were.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by Izkata on Tuesday March 24, 2026 @11:22PM (#47512856)
Wikipedia:

> In immediate mode, the scene (complete object model of the rendering primitives) is retained in the memory space of the client, instead of the graphics library. This implies that in an immediate mode application, the lists of graphical objects to be rendered are kept by the client and are not saved by the graphics library API. The application must re-issue all drawing commands required to describe the entire scene each time a new frame is required, regardless of actual changes.

React is simulating immediate mode by having the developer describe the full rendered result from the current data state. The developer / app code doesn't need to keep track of what changes need to be done to get the browser from its current state to the desired state, React does that for you.

Retained mode is where the developer / app does have to concern itself with the current browser state and issue the desired updates themselves, like how everything was done in the jquery era and earlier.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by user34283 on Tuesday March 24, 2026 @08:15AM (#47501517)
On the web you need accessibility and often also responsive layouts.

These are requirements the DOM / CSSOM addresses, you'd probably not have an easy time getting this right in a <canvas>.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by mpalmer on Tuesday March 24, 2026 @07:53AM (#47501323)
> Rather than passive-aggressively insulting my intelligence

I did no such thing. In fact I expressed my understanding of why you prefer your methods. I was hoping you would be willing to consider why declarative, composable UI patterns are worthwhile. Instead you substitute a deep topic for "React".

Have a good one, I have no intention of getting into a technical discussion with someone whose first reaction is to jump down people's throats.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by spoiler on Tuesday March 24, 2026 @08:15AM (#47501522)
No horse in this race, but your phrasing seems a bit weird, honestly... If reduced, your comments read as:

"You don't know about X? Well, at least I know about X and Y..." Doesn't seemed like a good faith comment to me either?

And then you say "You misunderstood my intentions so I'm going to disengage". For what it's worth, I didn't interpret your argument as insulting someone, but also it wasn't a useful or productive comment either.

What did you hope to achieve with your comments? Was it simply to state how you know something the other person doesn't? What purpose do you think that serves here?

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by applfanboysbgon on Tuesday March 24, 2026 @07:55AM (#47501347)
I guess I misinterpreted your comment? I do apologise if that's the case. I certainly didn't intend to "jump down your throat", I was asking you to explain your comment further because I don't understand what you're getting at.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by mpalmer on Tuesday March 24, 2026 @08:21AM (#47501583)
To be perfectly fair, you accused me of insulting you and said you "loathe" a word which I thought was a fairly inert term of art. Would you believe I didn't actually notice that you wanted me to say more? :) More than happy to give the benefit of the doubt though, the shoe's been on the other foot for me more than once.

For my part, I also loathe the insensate writhing mass of frameworks, patterns and dependencies that is "modern" frontend development. Where you and I differ is I recognize a handful of extremely good ideas hidden in the morass. But I am perfectly happy dismissing the majority of it; if nothing else, you shouldn't come away thinking of me as a React fanboy.

Writing is a lossy medium for thought, and programming is no exception. I'd say at a minimum that you and I are on the side of programmers whose code is a medium for their own thought.

All of these choices really just comes down to cognitive bandwidth, context, domain, taste, any number of things, really. Which is what was behind my first (admittedly terse, slightly salty) comment.

What I condemn is someone who opts out of making choices for themselves in their software. Web dev just happens to have an unfortunately high concentration of this sort of thoughtlessness.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by cluckindan on Tuesday March 24, 2026 @08:27AM (#47501644)
React is not immediate-mode in the traditional sense where everything is redrawn on every frame.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by chill1234 on Tuesday March 24, 2026 @08:34AM (#47501714)
Isn't that what reactive ui trying to achieve? To only have a render function and have ui state sync according to the data?
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by incrudible on Tuesday March 24, 2026 @12:53PM (#47505655)
Games do not sync data, they literally say what should be drawn on the screen, from scratch, 60+ times per second. They are in control of the entire process. They do not need to deal with DOM manipulation overhead because there is no DOM.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by chill1234 on Wednesday March 25, 2026 @10:34PM (#47526048)
Yes, in web to always draw from scratch, it would be slow, therefore exists reactive UI, so people can program like drawing from scratch but less slow.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by scoopdewoop on Tuesday March 24, 2026 @09:39AM (#47502444)
That is immediate-mode graphics. Fine when you are already power-budgeted for 60 frames each second. UIs typically use retained-mode graphics, with persisting regions.
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by cjonas on Tuesday March 24, 2026 @09:49AM (#47502581)
This is basically "reactive UI" foundation. The complexities come from effects (now managed via hooks)
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by monarchwadia on Tuesday March 24, 2026 @11:37AM (#47504245)
Well, in React specifically, you're describing the Flux architecture, which I've implemented manually back in the day. Its modern-day successor is Redux, which does exactly what you describe, but we found that it introduced more complexity rather than remove it.

I don't know about the other UIs, but on the web, some things impinge on the model you (and Redux) are proposing.

One thing is: you, in the gamedev world, have the luxury of having a frame buffer to write to. You fully control what gets rendered. Unfortunately, React and its cousins all have to deal with the idiosyncracies of the legacy browser environment. You have CSS, which applies and cascades styles to elements and their children in often non-obvious ways, and is a monster to deal with on any given day.

In addition to CSS, you have multiple potential sources of state. Every HTML slider, dropdown, input field, accordion, radio button, checkbox has its own browser-native state. You have to control for that.

On top of all of this, the browser application is usually just a frontend client that has to interact with a backend server, with asynchronous calls that require wait-state and failure-state management.

One thing that's in common with all of the above problems is: they're localized. All of these things I'm describing are specific to the rendering layer and therefore the component layer; they are not related to central state. A central state trying to capture all of these problems will fail, because component state has to be wrangled locally near where the HTML is; CSS also is component-level; and the network states are often very closely related to each component. If we maintain a central "game state", the data complexity just proliferates endlessly for each instance of the component.

So, the default these days is to keep state very close to each component, including network state, and often business logic also gets sucked into the mix. I try to avoid putting business logic in components, but people do it all the time unfortunately. But it does add to the complexity.

In other words, there is -real- complexity here, stemming from the fact that the web was never built to be a distribution+execution layer for rich applications, but evolved to become exactly that. It's not just bad application architecture or bad decisions by React maintainers.

Maybe I'm wrong, since I'm not a game developer and don't see what you're seeing on your side.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by applfanboysbgon on Tuesday March 24, 2026 @12:09PM (#47504853)
I'm sympathetic to "it's the browser's fault", to some degree. I understand that the browser locks you into certain constraints, and I understand that I don't understand much about those constraints, because most of the extent of my experience with web development is using a canvas and a couple of fundamental APIs to render my games via WASM as web is one of my build targets (and I do know that approach is undesirable for regular web pages).

What I don't understand is why the browser is that way in the first place, and why all of the native, not-browser GUI frameworks that people use are also that way. People opt into using React Native, even.

> the browser application is usually just a frontend client that has to interact with a backend server

I will note that this is a constraint that is shared with gamedev. Most multiplayer and even many singleplayer games these days are server-based.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by pier25 on Tuesday March 24, 2026 @12:42PM (#47505473)
Games can afford the luxury to re-render everyting on every frame. The DOM? Not so much.

This bottleneck could be alleviated if browsers shipped native dom morphing or even some kind of native vdom but we're stuck with userland js solutions.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by tmanderson on Tuesday March 24, 2026 @01:55PM (#47506583)
lol this is why so many game UIs are awful (how much they lack in terms of OS accessibility, keyboard controls/shortcuts, etc)
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by potsandpans on Tuesday March 24, 2026 @03:12PM (#47507638)
> I genuinely don't understand why this model is the norm. As a game developer working in my own engine, UI is unbelievably straight-forwar

I can't really think of a statement that resonates with me less.

Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by wonnage on Tuesday March 24, 2026 @04:32PM (#47508769)
Congrats, you described imgui which is basically react
Re:No-build, no-NPM, SSR-first JavaScript framework if you h... by sureglymop on Tuesday March 24, 2026 @05:10PM (#47509383)
This made me immediately think of the Elm architecture.

To an extent this is how react works internally. There is a function which takes state and produces UI. In order not to have to re-render the whole UI if only a small part of the state changes, there is a diffing algorithm and "virtual dom" that is diffed against. Maybe it doesn't work exactly like that anymore but that's the gist of it.