2 ms·
I can sympathize with the “mountain of JS” but SPAs way easier to reason about in abstract. In SPA world there’s an API server which is self-contained and has c
by Spivak 5y ago
I can sympathize with the “mountain of JS” but SPAs way easier to reason about in abstract. In SPA world there’s an API server which is self-contained and has clear boundaries — take JSON payload ish and return JSON payload ish. Server has no knowledge or connection to any client.
Client is a static bundle of JS and assets which just calls the API just like our iOS/Android/CLI.
Once you involve SSR (beyond hydration) you’re in for a world of hurt because you’re mixing the two. The JS doesn’t know about the HTML despite them hard depending on one another and the two processes can’t communicate back and forth anymore. Both sides are disconnected but have shared state because half of the client is actually on the server. Way more complicated than every half keeping its own books without any care. If it weren’t for “it’s what we had to do back then” it would be considered nuts to codegen whole applications and then send them across the network to run but that’s SSR.
- erikdoe 5y agoIn my opinion the reasoning why "SPAs [are] way easier to reason about in the abstract" is neglecting to acknowledge that most applications evolve over time. There is no well-defined API on the server side. The application logic is smeared across code the runs in the browser and code that runs on a server. That "API" is usually merely an HTTP endpoint that connects both sides. Adding new functionality to the application requires touching both sides, and changing the HTTP endpoint. I would use different approaches to build those HTTP endpoints and to build a "proper" API that's used by different consumers. Full disclosure: I'm one of the authors of the Tech Radar, and we've actually written about this coupling between the two sides of an app in a different context here: https://www.thoughtworks.com/radar/techniques/ui-bff-shared-types https://www.thoughtworks.com/radar/techniques/ui-bff-shared-...
- brtkdotse 5y ago> In SPA world there’s an API server which is self-contained and has clear boundaries — take JSON payload ish and return JSON payload ish. In theory yes, in practice I’ve more often than not seen the same team build both client and API meaning they’ve just added a bunch of operational complexity without having anything to show for it.