News for hackers. Stuff that matters.
Re:A modest critique of Htmx by shepherdjerred on Tuesday October 08, 2024 @10:53PM (#41784034)
I just don’t understand this opinion.

Backend (and frontend!) can be use stable technology choices if you want to. There are also plenty of bleeding edge libraries/frameworks/languages that come out every week.

As an example, how do you want to deploy your backend? VPS, severless, Kubernetes? What database? Which language? Which libraries?

There are boring stable answers to the above for backend, just like there are boring stable answers to frontend.

Really, I think you’ve just found those boring stable options for the backend and you haven’t done that for the frontend yet.

React has been out for more than a decade and it’s the dominant way of building UIs. And there are pros and cons to this with 1000 solutions, but, really, plain React will work for most things you want to do.

Re:A modest critique of Htmx by WD-42 on Tuesday October 08, 2024 @11:23PM (#41784202)
What exactly is "plain React" though? Not sure I've ever seen a project that used only React and nothing else. It would seem you'd need a build step, at the minimum.
Re:A modest critique of Htmx by shepherdjerred on Tuesday October 08, 2024 @11:44PM (#41784312)
Yes, you would need a build step. create-react-app has existed for a very long time and works quite well though advanced applications tend to outgrow it.

Alternatives are Webpack (stable, boring), Vite (starting to overtake Webpack since it's significantly simpler), and 1000 other libraries.

Again, there is some movement here, but Webpack has been in a dominant position for nearly a decade and there's no reason you can't continue to use it today if you value stability. It's the equivalent of choosing to host your backend on a VPS instead of trying out serverless.

Needing a build step is part of the complexity of frontend. I think frontend is getting much simpler with build tools like Vite and the addition of ES modules. But, even with these new things coming out, you can stick to your boring stable choices on the frontend just like you can on the backend.

Re:A modest critique of Htmx by WD-42 on Tuesday October 08, 2024 @11:56PM (#41784390)
Yea I'm not really buying it. create-react-app is deprecated. https://react.dev/learn/start-a-new-react-project points you directly at Next.js as a *starting point* and the section about using React without a framework does it's best to discourage you from doing it.

This is insane for beginners.

Re:A modest critique of Htmx by nsonha on Wednesday October 09, 2024 @02:43AM (#41785158)
You use a lot of words to respond to such a minor point. The main point is that actual "plain react" is useless. You need at least a router, some way to manage state, some way to manage style and so on. It's why nextjs is so popular, they are practically "plain react"
Re:A modest critique of Htmx by __jonas on Wednesday October 09, 2024 @09:47AM (#41787939)
Useless is a massive exaggeration.

> You need at least a router

You only need a router if you want to build a SPA with different routes, not all web applications are that! Tons of practical React apps are just a single screen, or even embedded component.

> some way to manage state

You do not need an external library for complex state management, the React docs have some great guides on how to achieve this with plain React:

https://react.dev/learn/scaling-up-with-reducer-and-context

> some way to manage style

Plain CSS and the JSX style property are entirely enough for most apps. If you are using a build tool like Vite, you can also do CSS modules for scoping styles to your React components for more complex applications. I do agree that styling is not a strong point of React, but I don't think pulling in a dependency is necessary.

Re:A modest critique of Htmx by nsonha on Wednesday October 09, 2024 @11:20AM (#41788839)
> https://react.dev/learn/scaling-up-with-reducer-and-context

I just wanna vomit reading that article (which is in official docs!!!). There is a much cleaner way of managing state with just a single `useState` per component instead of bringing over some Redux dogma for some inexplicable reason:

```

const [state, dispatch] = useState()

// ...

dispatch(doThis)

dispatch(doThat)

```

Re:A modest critique of Htmx by __jonas on Wednesday October 09, 2024 @12:14PM (#41789581)
Well of course component state is what you reach for first, which is why it is the first four sections of those docs about state management I linked:

https://react.dev/learn/managing-state

I was linking this later section about extracting state logic into a reducer, because you suggested that you would need an external dependency for state management, I assumed you were talking about something like redux.

But of course you can get pretty far with a single useState and prop drilling as well. Not sure how it supports your point that 'plain react is useless', it sounds like you are arguing against yourself with that comment?

Re:A modest critique of Htmx by nsonha on Wednesday October 09, 2024 @08:34PM (#41794341)
No it's a different point, in this, I just wanna express how ridiculous the official React docs can be sometimes.

The Redux "pattern" you speak of, does nothing to manage state better than useState(). So I'm not sure why that API even exists, or why you think that is a good response to "need something to manage states".

Let's go back to that, managing state would be for example error and pending state for every async action. In react, that basic, repetitive task is a whole celebration if you just do plain. Try do do form with per-field back-end validation feedback and see how much boilerplate you need for that.

Re:A modest critique of Htmx by __jonas on Thursday October 10, 2024 @08:01AM (#41797980)
Alright sure, I guess I just don't understand what it is "you need" for state management then, but I don't want to get caught up in this too much, you've made your point.

I 100% agree that React is super boilerplate heavy, a lot of things are indeed 'a whole celebration', I personally choose something like Svelte over React if I have the choice, because I don't enjoy that either. All I'm saying is that plain React is not useless! It's completely fine. I don't mind working with it, it makes a tradeoff of being more ceremony but perhaps less magic and I think the tradeoff is okay.

Re:A modest critique of Htmx by ywvcbk on Thursday October 10, 2024 @04:08AM (#41796677)
Now store all of those states in an URL or some other place that would allow you to recreate the full view after the website is reloaded or in a new session.
Re:A modest critique of Htmx by shepherdjerred on Wednesday October 09, 2024 @07:47PM (#41794049)
Here’s an example of a single page React app that I wrote several years ago that requires nearly zero maintenance, is a single screen, uses Bulma for CSS, and manages state w/o an external library

https://better-skill-capped.com/

Re:A modest critique of Htmx by ywvcbk on Thursday October 10, 2024 @04:05AM (#41796671)
It’s an app with a bunch of random components, though not really a website.

If you want an actual website with proper routing and possibly SSR and want to use “plain” React with no additional libraries you’ll have to waste a lot of time reinventing the wheel.

Re:A modest critique of Htmx by agos on Wednesday October 09, 2024 @04:30AM (#41785713)
FYI, create-react-app is basically abandoned since two years. Maybe it still works but if there's any bug, good luck
Re:A modest critique of Htmx by chrisweekly on Wednesday October 09, 2024 @09:55AM (#41788036)
CRA is dead. Vite has emerged as its successor.
Re:A modest critique of Htmx by roywiggins on Tuesday October 08, 2024 @11:33PM (#41784262)
You only really need a build step to use JSX, which is strictly speaking optional.
Re:A modest critique of Htmx by shepherdjerred on Tuesday October 08, 2024 @11:45PM (#41784315)
This is true (and part of why I love React/JSX) but in practice nobody writes JSX by hand.
Re:A modest critique of Htmx by cowoder on Wednesday October 09, 2024 @04:55AM (#41785835)
Isn't it the other way around, nobody writes React by hand they all use JSX?
Re:A modest critique of Htmx by shepherdjerred on Wednesday October 09, 2024 @09:58AM (#41788069)
You're right :)
Re:A modest critique of Htmx by Lutger on Wednesday October 09, 2024 @06:27AM (#41786282)
Technically you don't even need react, you can do it all in javascript!

Joking aside, you really do need to solve the problems jsx solves, but also webpack, next.js, react-router and depending on your application, something like mantine or tailwind. These are the minimum I think.

If you have a smallish project you can get by hand-rolling your own solutions, but it doesn't make the problems themselves go away.

In fact, it is exactly the claim in this thread that there are a lot of beaten paths in backend languages with relative stability over time, whereas in frontend it is 1) not clear what the beaten path is (there isn't one) and 2) when there appears to be favored solution, it often changes radically or disappears after just a couple of years.

For example, create-react-app used to be the default way to start a react app, it is now deprecated. But for python, Django has been a stable beaten path for many, many years. Same for Rails. C# also tends to change every couple of years, but there is always just one single Microsoft recommended way to do things.

Sure there are many experimental libraries and contenders in these languages as well, but there isn't really anything with the same maturity and stability in frontend.

Re:A modest critique of Htmx by fijiaarone on Monday October 21, 2024 @10:19AM (#41904472)
you can always just do:

    <script src="react.js">
    <script src="react-dom.js">
    <script> 
    const recognition = undefined
    var foo = document.querySelector("#foo")
    let bar = ReactDOM.createRoot(foo)
    foo.innerHTML = bar.render("<b>eyond<a>ll{recognition}");
    </script>
Re:A modest critique of Htmx by aprdm on Wednesday October 09, 2024 @06:47PM (#41793625)
You don't need a build step if you do everything in javascript without jsx. I have done it like that in the past on air gapped environments (and vendored the deps)
Re:A modest critique of Htmx by Lutger on Wednesday October 09, 2024 @06:15AM (#41786210)
React proper may be more or less stable since hooks came out 6 years ago, on its own it isn't sufficient. You still need to think about react-router, mobx, redux, nextjs, remix, vite, tailwind or mantine or material ui or whatever. And some of these have changed radically from year to year. The react ecosystem is not stable.

It is unavoidable to have a truly gigantic amount of (transitive) dependencies, and its rare you go a month of updates without it breaking your app.

It is true that for backend it is more or less the same, however it is a matter of degree. If frontend is all you do, it may be managable, but for full-stack devs who also need to manage infra it can sometimes be overwhelming.

Re:A modest critique of Htmx by __jonas on Wednesday October 09, 2024 @09:10AM (#41787580)
> You still need to think about react-router, mobx, redux, nextjs, remix, vite, tailwind or mantine or material ui or whatever

You really don't need any of this though, you can get super far with React alone, and the new docs on react.dev are great at explaining this and pushing this idea in my opinion.

Re:A modest critique of Htmx by fijiaarone on Monday October 21, 2024 @10:07AM (#41904333)
React alone is just a bad template library.
Re:A modest critique of Htmx by shepherdjerred on Wednesday October 09, 2024 @09:55AM (#41788038)
> react-router, mobx, redux, nextjs, remix, vite, tailwind or mantine or material ui or whatever

You don't need any of this (aside from a bundler). That's my whole point. You can use these libraries and be on the cutting edge, or go with something simpler.

You'll have the exact same problem on the backend if you want to use a library for everything.

Re:A modest critique of Htmx by alexanderchr on Wednesday October 09, 2024 @10:00AM (#41788090)
> It is unavoidable to have a truly gigantic amount of (transitive) dependencies, and its rare you go a month of updates without it breaking your app.

I've maintained a sizeable react app for 8 years, and this has not been my experience at all. Maybe 10 years ago things would break monthly but nowadays things are quite stable, with very reasonable deprecation schedules and upgrade paths. I have lots of code running that I haven't touched in 5+ years and it is not causing any problems even when I'm keeping the main parts of the appliaction up to date with modern practices.

Re:A modest critique of Htmx by shepherdjerred on Wednesday October 09, 2024 @07:45PM (#41794032)
I’ve had a similar experience but I’m tired of fighting against popular opinion
Re:A modest critique of Htmx by fijiaarone on Monday October 21, 2024 @10:07AM (#41904328)
Nobody claimed browsers were changing drastically, they're talking about front end frameworks.

There are a lot of green screen terminal apps that still work today, and haven't been touched in more than 5 years. As long as you leave the same code on the same machine once it's working, and keep the moths off the vacuum tubes and the power flow steady, there shouldn't be a problem.

But try to change that CP/M parts terminal so it can interface with your new EPR and see how well it "just works".

Re:A modest critique of Htmx by alexanderchr on Sunday October 27, 2024 @12:21PM (#41963675)
I’m not sure what makes you think I’m talking about browsers, because I’m not :)

My point is just that the React ecosystem has become surprisingly stable. Of course if you are going to continuously rewrite things into the current flavour of the month framework, you are going to spend a lot of time doing that, but keeping up with upstream changes in dependencies is not something I have found particularly burdensome.

To take the project I mentioned above as an example, currently it’s running on React 18.x, most dependencies are on the latest major version et.c. Still, much of the code is as it was written 8+ years ago, because the core APIs of React have been stable.

Re:A modest critique of Htmx by mattgreenrocks on Wednesday October 09, 2024 @08:53AM (#41787400)
The churn in React keeps me out. I also get really suspicious of tech that spawns mini cottage industries, where there has to be a React-ified wrapper for every single thing.

Maybe in 2025. I've learned Svelte 5 and think it is pretty good for the tradeoffs it makes though. And I think MPA is the right default for 95% of sites.

Re:A modest critique of Htmx by fijiaarone on Monday October 21, 2024 @10:09AM (#41904347)
As soon as Svelte 5 stabilizes you can start porting libraries to work with it. In the meantime, you can play with the tutorial in a textarea in a browser and feel as productive as you want.
Re:A modest critique of Htmx by jrochkind1 on Wednesday October 09, 2024 @10:12AM (#41788188)
I think part of the issue is that the "boring stable" choice for front-end, React, is disliked by many, and often doesn't actually seem very boring (if that means easy to understand how to do it right) or stable (if that means doens't drastically change much) to many.
Re:A modest critique of Htmx by zonethundery on Wednesday October 09, 2024 @10:15AM (#41788222)
I think the responses to your comment show the whirlwind of 'wtf?' confronting any programmer contemplating front end development for the first time.

What you wrote is probably true (and the one "see how far you can get in react only" comment is probably a decent path, but the landscape is overwhelming.

Re:A modest critique of Htmx by LegionMammal978 on Wednesday October 09, 2024 @10:35AM (#41788349)
Yeah, the frontend scene definitely suffers from hype-driven development: it's not good enough that we have a tool to do the job, we need the tool to be the bestest ever on every possible metric, so we end up with a treadmill of additional frameworks, bundlers, etc. that are hyped up in any given year.

E.g., I might think to ask, "Which tool creates the output with the lesser overhead on the client, Webpack or Vite?" But I can't find anything solid about that, since everyone's too busy hyping up the dev experience or whatever.

It's a shame that you have to swim against the tide so heavily, if you value simplicity over immediate kitchen-sink levels of functionality. Personally, I've landed on pure client-side React (with any bundler, or with Babel alone if you're feeling adventurous) since it doesn't try to have any purpose other than updating components according to state. Many of its competitors have too much poorly-documented magic for my taste.