45 points · by reimertz · 5y ago · 28 comments
This is blatantly wrong. The RFC (and Dan Abramov’s video) make it clear that server components can only be run on the server: https://github.com/josephsavona/rfcs/blob/server-components/...
I guess you can have components and hooks to share stuff between server and client?
Technologies that are fast to develop in but comprised of heaps of inefficient layers upon inefficient layers are possible in the first place because computers are powerful and have oodles of RAM. There’s so little punishment in the marketplace for websites for (ab)using system resources that it is the opportunity cost of failing to do so that dominates.
This assertion completely ignores the performance problems that are involved in "rendering html interfaces on the client".
The main difference between rendering "Call of Duty at 60fps" and rendering a SPA in React is where you decided to start counting. While your Call of Duty example presumes the app already in the post-init in-game state, your "rendering html interfaces on the client" only covers the app load and init state.
This means you are comparing a state where all data to output the first render is already fetched and available with a state where even the code that builds the app is not fetched yet and therefore at least a sizable HTTP request needs to be completed, followed by other sizable and non-pipelinable HTTP requests which are needed to fetch the data used to build up content and state.
Call of Duty does not need to perform and wait for at least two sequential HTTP requests to finish to be able to render a scene. Each HTTP request adds something between 50 to 100ms to the page load time. The topic of this discussion is a technique used to avoid having to wait for subsequent requests after the initial HTML+Javascript requests by simply prefetching and prerendering the content on the server. Consequently this approach avoids the need to make critical HTTP requests in the client-side by simply supplying the HTML and javascript with the client's intended state and content, thus potentially shaving over 50-100ms from a page load time.
HTML tech was never designed to run applications. It's for hypertext documents and nothing else.
But one can pervert any tech to do any kind of stuff. So people started to build "HTML apps".
Using inappropriate tools results in abysmal results. Simple like that.
If you use the right tool you can render GUI components even with microcontrollers. Have a look at Qt for example.
One could have of course all the nice things about "HTML apps", even if the GUI tech would be purposely build and separated from the rest of the stack.
It's just the "Web Platform" that's a completely inadequate base for app development. But nobody cares as "it works fine". The mantra is even: Oh, we have so much compute power and RAM! It would be a pity if we wouldn't use it to the limit of what's available. The idea behind: If your "app" doesn't use all the available resources "it wastes resources, as unused resources are wasted resources".
I for my part just can't put in words how completely nuts this line of reasoning appears to me!
Especially as on the other side of the fence people complaining about the massive waste of resources by "web tech"...
The solution is of course also simple: Just don't use the wrong tool for the job!
If you're not writing hypertext documents, but want to build an application, just use technology that was purposely build to support efficient (along all kind of axis) application development. With "native" tech there's no problem to render some GUI components. That worked flawless even back than on i486 PCs. The stuff in the past even felt much more responsive than todays web-tech GUIs.
But of course Google & Co. will tell you that you should build apps for their "operating system" (the "Web Platform"), or else...
(There is even a broader parallel to be drawn to the satiation in the 90'ies: Just think for a moment about Kubernetes and PWAs, about Google and MS Windows ;-) But this rant is already too long. I'm sure the people here are able to see that parallels without further explanation).
When your paying engineers 6-figures and can achieve target performance simply by buying more cores, it's often a good trade off.
When you're selling a game to the general public, hardware is relatively fixed.
----
Big companies spend a lot of time on performance, because it matters. When you're running with millions of dollars of compute costs, it actually meaningful to optimize the code to save cores.
I was listening to a talk by Jonathan Blow the other day where he was saying using interpreted languages (like lua) inside a game engine isn't considered good practice anymore. And indeed, in unity most games write all their logic in C# - which unity somehow compiles down to native code.
We are using a document markup language to create interactive UIs. Which, for some crazy reason, has taken over the rest of the industry as well. I have a TV with a React UI, which takes around a second to respond to actions on my remote control. Decades ago, TVs were responsive, even though they had a minuscule amount of processing power compared to modern ones.
You'd think that people would recognize that the web was not meant for what it is used today and would standardize on an alternative with similar benefits (easy debugging, quick feedback cycle, modern tooling) that would actually allow us to build proper interactive UIs, but apparently it is impossible to develop new software. Please, someone, kill HTML.
Your personal assertion makes no sense. This is a purely technical problem, not a project management one. If you need to load a page and load a script and load data, and each load takes you around 100ms, then you don't change any of that with project management changes.
Technical problems are addressed with technical solutions, and this article shows you one: prerender the content on the server-side to avoid having to wait for data fetches to get the initial page load to finish.
> We are using a document markup language to create interactive UIs.
Your remark makes absolutely no sense and has no bearing with either the problem domain or the discussion. The markup side of things is not a problem. Parsing and rendering HTML is not a problem. HTML does not even feature in this discussion at all.
Please bear in mind that you are posting comments on a discussion on, to put it clearly to you, procedurally generated websites. This is about a server-side rendering technique for React applications. In case you are unaware, React is a javascript frameworks that is used to generate and manage the DOM. The "markup language" side of things barely even registers as boilerplate to specify the entry point. It's the javascript script that you run after the HTML is loaded that assembles the document tree.
> You'd think that people would recognize that the web was not meant for what it is used today
Your comment makes zero sense, and reads like a non-sequitur rant.
It took some time and flailing about in the community. But fortunately there was a relatively quick and massive structural change to programming large web front ends with compontent-based JS over the years.
Much like Rails, the problem wasn't the language per-se, but a broad consensus regarding the best approach and having structure community wide helps solve a lot of problems.
Now we finally have reached a pretty close consensus on the 'framework' side. Plus I'm also excited on the build systems side - as they are getting closer to just 'importing' other JS files instead of the endless magic of Webpack processors and similar hackery.
So with that area finally quieting down, performance optimization around SSR and pushing as much to the server-side in general is also finally reaching maturity. This is a critical piece of the puzzle. And probably the last major hurdle for serious performant JS-heavy frontends.
Heavily interactive web UIs are not going away no matter how many minimalist or anti-frontend-JS articles get posted on HN and elsewhere.
Countless SaaS products depend heavily on stuff we've had on desktop for ages (most legit critiques apply to miss-use-cases, not inherent issues). And their potential for serious interfaces with well managed client-side state, consistent abstraction layers with components, clean UI logic, etc, instead of ungodly spaghetti messes that were difficult for dev teams to manage - ones that would changed dramatically every time a new dev/manager was hired - or simply trying to hack full-on Rails style MVC but purely client-side (see: backbone.js), is finally coming to and end.
I'm personally a Vue, not React guy, but there's no question most advancements and experimentations happen in React's community first. Which a fine by me, as the good pieces always filter down to Vue quite quickly. SSR and deeper server integrations are clearly the way to go for any serious web app. The only downsides I've seen are they mostly JS server frameworks.
I think one missing piece that’s far from mature is data fetching. It’s really hard to get something working well at scale:
- REST is simple, but you end up with serial waterfalls for complex fetches.
- GraphQL avoids these waterfalls and lets you collocate declarative data with your components. This is great if your server layer supports it well.
- You also need a way to fetch all descendants’ data high up the tree (to avoid serial fetches). Relay does this with a compilation step, and requires passing pointers back down the tree for runtime use.
- Updating data (POST, PUT, Mutations) is super tricky to do in a way that keeps data consistent, avoids over-fetching, handles exceptions and idempotence and retries right, etc.
I wish there was a standard here, but I think we’re still pretty far from it.