this post was submitted on 01 Sep 2023
64 points (93.2% liked)

Programming

17383 readers
435 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

React (and Vue, et al) was built with client side rendering in mind. It just does not seem to fit the server side rendering pattern.

What are the use cases? From my perspective, if your app is a rich web app with a lot of interactivity, you probably want CSR and don't benefit much from SSR.

If you have a content-centric site, or a site with some interactivity but not much, you want a static site generator, or SSR. But in that case, a template engine with some smaller client side libraries (jQuery or AlpineJS or idk what all is out there).

Using React SSR for all of these seems like the wrong tool. What am I missing?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 36 points 1 year ago* (last edited 1 year ago) (3 children)

The mere existence of the term "server-side rendering" illustrates this well. I remember the first time I read about that concept and immediately thought "you mean the way we've been writing websites since the 90s?"

Maybe I'm just out of date, but IMO web development has completely lost its way. I don't do much frontend work anymore, but when I do my goals are always to see how few JS libraries I need to use and how little JS I need to write in general. The end result of that plus doing all/most work on the backend, sticking to standard HTTP conventions, and using only vanilla JS means super fast and performant websites with fewer bugs, less constant deprecations to keep up with, less security vulnerabilities in all the JS libraries, and no constant headaches from a complex Webpack-style build system for assets. It's actually quite enjoyable when you remove all the bs of modern JS frameworks from your workflows.

[–] lysdexic 6 points 1 year ago (1 children)

I remember the first time I read about that concept and immediately thought “you mean the way we’ve been writing websites since the 90s?”

This is a poorly informed take. Your pop's dynamic html server side rendering has nothing to do with the problem of rendering DOMs generated by JavaScript running in a browser according to the client's state and leave it in a coherent state. Trying to pass off React's SSR for the same thing that was done in the 90s is like trying to pass off an Android app as the programs written for DOS.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

Is it not generating HTML on the server to be served to the client? What you're describing is, in my opinion, an overly complicated form of dynamically rendering HTML on the backend. It's exactly what I'm talking about: the layers and layers of complexity modern web development has added hasn't really solved any problems but rather primarily created problems which are solved with another layer on top as a fix which has problems of its own, and repeat.

Anyway, that's my opinion on the matter, I've toiled with modern web development tools my fair share and time and time again found that removing all of them in favor of vanilla JS where strictly needed and traditional dynamic backends is the most reliable and performant, and frankly enjoyable form of web development. I know others like those workflows and the complexity/power they bring and that's fine, it's not my cup of tea though.

[–] lysdexic 3 points 1 year ago* (last edited 1 year ago) (1 children)

Is it not generating HTML on the server to be served to the client?

No, it generates the code that creates the DOM, sets the application state based on the user's setting, and updates the webapp to resume working in a consistent state.

It basically sends a frozen instance of a full blown JavaScript application.

What you’re describing is, in my opinion, an overly complicated form of dynamically rendering HTML on the backend.

That's because you're oblivious to the problem domain,and thus you're falling back to the unrelated but similar sounding things you're familiar with to fill in the void of your understanding of the actual problem.

Anyway, that’s my opinion on the matter

My point is that your opinion is a misinformed one,and really doesn't hold up to scrutiny.

[–] [email protected] 1 points 1 year ago

Alright, I'm not going to get into an internet pissing contest over front end techniques since despite being in the industry for over a decade I've been deemed oblivious and misinformed based on two comments. I'll keep doing things my way and you can do it your way. I'm not going to lose sleep over it or resort to calling names over a comment on the internet of someone's opinion I don't agree with.

[–] [email protected] 6 points 1 year ago

My hot take is that I find it so much more pleasant to write typescript and do most of the work in the front-end rather than deal with optimizing the response time of the backend day in and day out. With SPAs it's so much easier to fetch just what is needed rather than have monolithic responses that take ages to arrive. Makes caching and cache invalidation that much easier too.

[–] hairyballs 1 points 1 year ago

Htmx is a godsend for that. You actually write HTML while having AJAX easily.