Hacker News new | ask | show | jobs
by kaoD 382 days ago
Maybe it's where I'm imagining we're headed (and not where we're actually headed) but I think it will bring us into the sweet spot that I want/need: good old PHP-like server-rendered sites (or even static pages) with custom interactive components (think e.g. forms with client-side validation) without the mess that mixing PHP+jQuery used to be.

Server rendering is enough for the 80% use case. Browsers are optimized for it. Sprinkle interactivity without the impedance mismatch of jQuery and you're in heaven. No more overengineered state syncing between client and server. Just. Fetch. HTML.

Currently frameworks are trying to shoehorn it into the 2018 React mindset but that's not what I think is needed for them to succeed.

2 comments

I think RSC is trying to answer the question, “How can we make server rendering and sprinkles of interactivity composable?” What if you want your sprinkles to have server rendered content inside of them, each of which may contain other interactive/dynamic elements?

I posit that any composable version of sprinkles or the “island architecture” will closely resemble RSC.

Only a small fraction of apps will ever use the full power of the RSC architecture. However, the React team doesn’t build apps, they build primitives for building apps. And good primitives are composable.

Yeah that is the right answer imo.

What they did wrong tho was to morph React into this mess. RSC should be React Server and live along React DOM and React Native, something almost unrelated to the previous concept of React. But we got this an entangled mess.

You either make presentation the server job or the client job. Spreading it between the two results in the same trouble that distributed systems are trying to solve to this day. At least backend have a reason for going the distributed route (resources and risk management).
> You either make presentation the server job or the client job

Is that your axiom or do you have any justification? I just don't agree with it.

Why should the server know about a datepicker's internal details?

It's all relate to consistency. If presentation is the job of the server (html templates), the server is the source of truth and the client state is expected to be transient. That is a good model for most web applications including this forums.

There's some case where local state is more important (figma, google maps, chat app) and the backend is expected to act as a data source with a domain-specific API. Any mixture between the two and you will make the separation between the two domain (server concerns and client concerns) at the wrong place, making the design more complex (however well you hide it behind the curtains).

> If presentation is the job of the server (html templates), the server is the source of truth and the client state is expected to be transient.

Which is exactly why the client state should be transient non-application state like datepickers, dropdowns, text boxes, etc. and it does not belong in the server (essentially what jQuery was used for back in the day, interactive sprinkles). And the other way around.

Perhaps you agree with me but there was something lost in translation?

Something was lost. I was arguing either send the presentation layer as data to the web browser as resources, or send data that from which the browser and the UI library (react, svelte,...) will derives the UI from.

RSC does a weird split where the engine is the same on both ends instead of a clear separation layer where one does not need to know about each other. I much prefer HTMX approach (samey old backend where you mostly take care of everything in the frontend) and Laravel Livewire approach (where you take care of everything backend side, with optional client side scripting).

No need to reinvent the world to fix a single problem.