Live data from Hacker News

If not React, then what?

infrequently.org

621–630 of 756 posts

Re: If not React, then what?

#621

Earlier quoted context omitted.

If you’ve never used it don’t declare it dead. Angular is updated regularly every 6 months. While react is busy thinking how to create more SSR apis, the angular team keeps improving developer experience. IMO right now it’s easier to start an angular project with much less foot guns than react.

I call plenty of things dead without ever having used them. FORTRAN for example. What I mean by dead is it's a VERY unlikely choice for any new app. People will choose React or Vue most of the time. You don't see Angular used hardly ever for a new project. BTW: Vite is the new best way to manage the build pipeline, and makes React super easy to start using.

I’ve never used a drill press; does that make them dead?

Fortran certainly has its issues with portability and feature development, but it is by no means dead.

Re: If not React, then what?

#622

Earlier quoted context omitted.

WebAssembly can't do anything without Javascript. You're still using the same annoying Web APIs with another layer of indirection between. Plus, now you're using the slow Rust compiler so your iteration times are going to suffer. We already have type-safety in Typescript. We don't have to care about lifetimes, either.

Agree that WASM cannot yet directly manipulate the DOM. But are build times in JS/TS framework world any slower than Rust compile times? I'm not convinced on this point. As a disclaimer, I still prefer vanilla JS and progressive enhancement.

TS is very fast with esbuild and the likes, it's basically just stripping off the type annotations. Your setup may vary, of course.

The other point isn't so much that there's a wrapper around the DOM, but that the DOM API itself is bad and slow. There's only so much pain a better language can take away here, and Rust isn't even a better language for that domain.

Re: If not React, then what?

#623
post #485

Earlier quoted context omitted.

How do you fetch and persist server side data without useEffect? (Assuming vanilla react)

That’s probably the main real-world use case for useEffect. Dedicated third-party libraries like React Query obviously use useEffect under the hood as well

Yeah that's what I thought -- all the React codebases that I've worked in are riddled with `useEffect` for this reason primarily.

Re: If not React, then what?

#624
post #590
post #532

Earlier quoted context omitted.

> Specifically, what problem does it solve, and do I have that problem? The problem most teams tend to face, and I believe part of the authors argument is that people reach for React out of an almost superstitious or orthodoxy-based belief. The problem is building a front-end UI with compositional components (essentially the only way to build anything substantial), with sane handling of state, and with acceptable per…

> The problem is building a front-end UI with compositional components (essentially the only way to build anything substantial) Server-rendered front end frameworks (like Rails) have units of composition as well (partials, helpers). > with sane handling of state, and with acceptable performance for interactive use (which means not round-tripping to the server every time, sadly, otherwise I'd keep using Wicket) What "…

> What "state" one needs to handle is app dependent. Some do need client-side interactivity and some don't. Obviously, if you need it, you need it. Saying "almost everyone doing front-end work has that problem" is something you'd have a hard time proving. Historically, most things people have built on the web have had relatively low levels of interactivity. There are brochure sites (read-only) and there are forms-over-data (read, with data entry) that both lend themselves well to a server-rendered approach.

As soon as you have any kind of interactive UI, either you do sever roundtrips for everything (which is usually unacceptably slow) or you have client-side state. Tabbed form section? State. Two-level dropdown? State. Radio button enabling different parts of your form? State.

Theoretically it's conceivable that someone might have a website that needed only flat forms with zero dynamism. But I've found that everyone thinks their website is like that, and they're always wrong. Every Rails/Django/Wicket/etc. site ends up needing one little piece of unmanaged JavaScript somewhere (unless you're lucky enough for a server roundtrip to be acceptable latency-wise). And then one more piece. And then you have a state management problem.

> My team maintains 30 or so Rails applications complete with collaborative two-way sync form entry and real-time (enough) commenting with server rendering and Rails. The first app we built used React. I can tell you with absolute certainty (because I've done it) that the React version is still more expensive to maintain, still the place that the devs prefer to work the least, still the most expensive to extend.

You must see that your experience is unusual - perhaps you're using React badly (understandable in a first app), or your team has spent more learning time on Rails. There are scenarios where Rails might beat React on a level playing field, but this shouldn't be one of them. Apart from anything else, how do you do handle the client-side state in the Rails case?

> HTML is what React renders. You need to write something like it when you write your JSX.

Right, just as your Ruby runs via a C interpreter that ultimately executes as machine code, is the analogy I was drawing. Having a bit of familiarity with C and your processor's assembly might be helpful for some kinds of debugging occasionally, but it probably shouldn't be a priority.

> Server-side rendering is necessary if you want anything resembling reasonable time-to-interactive

I assure you it isn't. In some use scenarios it might be, but I've worked on sites that were very fast without it.

> or SEO.

Perhaps - but not everyone needs SEO.

> Progressive enhancement is something every web developer has to at least be aware of when it comes to CSS.

It really isn't these days. Even a very inclusive baseline of browser support still gives you plenty to work with - e.g. flexbox is 12 years old at this point. It's entirely practical to set a reasonable baseline and just not do progressive enhancement (particularly since often the "worst" browser you're targeting - iOS Safari - is also the one that most of your customer base by value uses, so there's little to gain from progressive enhancement).

Re: If not React, then what?

#625
I'm trying to build server rendered websites, but I find React (or other SPA-API systems) hard to resist:

- Form is hard. Doing it in backend make it even harder when the form is complicated. For example, a form with tab needs JS to operate and you need to signal the JS which tab the error is.

- If you're using backend form framework, you don't have control over the HTML unless you learn the hook points of it (do you add attribute in code, or in template? Where is the default template to override?) Compared to frontend framework where you can paste the CSS framework's example HTML.

- I wanted to build a new user wizard, which should be easy with a frontend framework as you can easily store incomplete state in memory. If not using JavaScript one would have to store the state in the untyped session variables, add hooks cluttering the HTML template, etc.

- Progressive enhancement is easier when you have to write the code only once. If there's a table and you want to refresh without refreshing the page, in React you just call the data fetcher again. In HTMX your backend needs to have a "full render" endpoint and a "table only" render endpoint. If you're using jQuery you might as well write the table loop twice in the backend template engine and in jQuery.

- I haven't see any good backend framework (be it Django, Laravel, Symfony, Gin) that has similar server-rendered frontend component like React. Many frameworks believed that logic should be precomputed in the view layer and the template engine should not be turing-complete.

I was thinking about moving to SSR-rendered SPA, but I know of no Next.js-style library for any frontend framework that actually allow form submission without JavaScript AND progressive enhancement with JavaScript using the same code.

Re: If not React, then what?

#626
post #610

Earlier quoted context omitted.

It seems you only want to call MVC frameworks frameworks? But there's millions of other types of frameworks for thousands of purposes. Framework is a generic term (for which the definition is usually the calls into you/you call into it thing). What it does and whether it's a framework is two completely orthogonal things.

> It seems you only want to call MVC frameworks frameworks? No, I'm illustrating the limited scope of React. I wouldn't call a chunk of code that handles the V in MVC a framework. > for which the definition is usually the calls into you/you call into it thing Again there's nuance here: import { useEffect, useState } from "react"; import { createRoot } from 'react-dom/client'; document.body.innerHTML = ' '; const root…

> I'm "calling into" react (3) times here, while react is calling "into me" (1) time.

It's calling into you three or more times, invisibly, if I remember the details of what useEffect and useState actually do at runtime correctly. Which rather illustrates the point.

> Are we saying any external source code that accepts a function as a parameter is considered a framework?

Code that accepts a function for narrowly scoped use where the control flow is still under your control (e.g. map/reduce/filter libraries) is probably not a framework. But external code where you register a callback that gets called some time later, not under your control, is pretty much the definition of a framework.

Re: If not React, then what?

#627
post #590
post #532

Earlier quoted context omitted.

> Specifically, what problem does it solve, and do I have that problem? The problem most teams tend to face, and I believe part of the authors argument is that people reach for React out of an almost superstitious or orthodoxy-based belief. The problem is building a front-end UI with compositional components (essentially the only way to build anything substantial), with sane handling of state, and with acceptable per…

> The problem is building a front-end UI with compositional components (essentially the only way to build anything substantial) Server-rendered front end frameworks (like Rails) have units of composition as well (partials, helpers). > with sane handling of state, and with acceptable performance for interactive use (which means not round-tripping to the server every time, sadly, otherwise I'd keep using Wicket) What "…

Not really surprising that a rails shop is going to have a easier time with rails than react.

Re: If not React, then what?

#628
post #109

Earlier quoted context omitted.

Leptos is even worse than React in memory consumption and startup metrics. https://krausest.github.io/js-framework-benchmark/current.ht...

But faster overall, one code base front and back, and it will only improve as new WebAssembly features roll out (js-string-builtins, Memory64, eventually component model DOM access). And any high performance functions you need on the front end will be higher performance than JavaScript. Like bloom filters for example: https://nuenki.app/blog/bloom_filters_optimisation

> But faster overall

Only in further updates to the DOM. There are very few use cases where you need to continually update thousands of DOM elements.

For most use cases, start up time and memory usage are really the most important metric.

Re: If not React, then what?

#629
post #126

Earlier quoted context omitted.

You're missing the point of my comment. Someone is contesting that "frameworkism isn't delivering" when we have objective data to prove that it is in fact not delivering. The Amazon store is just a good example because there's a lot of data about it, not because it's FAANG.

You just picked Amazon arbitrarily because it supports your argument, but there are many more counter examples where react is used, so what's your point?

I used Amazon because there's a significant amount of data to indicate React is a bad fit for e-commerce (as the OP article points out).

Re: If not React, then what?

#630
post #126

Earlier quoted context omitted.

You're missing the point of my comment. Someone is contesting that "frameworkism isn't delivering" when we have objective data to prove that it is in fact not delivering. The Amazon store is just a good example because there's a lot of data about it, not because it's FAANG.

What I read from what you said is “Chevy trucks are good? Oh yeah, if trucks are good, why does the post office use non-Chevy, non-truck, fleet cars?” Please help me understand where I misunderstand

"Trucks are bad for X"

"No, trucks are good for X"

"Look at this use case (Amazon) with tons of objective data that shows that trucks are bad for X"

Post reply on HN