News for hackers. Stuff that matters.
Re:React has grown beyond its original promise and it's caus... by MattDaEskimo on Thursday February 08, 2024 @07:51PM (#39309969)
This sounds like the complaints from a new developer that's frustrated over the layers of web dev.

React does a fantastic job working with common developer principles such as Don't Repeat Yourself, and Single Source of Truth.

Their points come across as overly vague and lack any true insights into development besides initial impressions.

For a static page it doesn't make sense to use React, obviously. For a highly interactive page it, or another framework is critical to clean, manageable code.

Re:React has grown beyond its original promise and it's caus... by tauchunfall on Thursday February 08, 2024 @08:06PM (#39310095)
>For a static page it doesn't make sense to use React, obviously

JSX is a nice templating language. And when you use Deno or Bun you can use it directly on server-side. My server-side components have no hooks and use preact-render-to-string or `renderToString()` from `react-dom/server`.

Also there is Gatsby which is a popular content management system which also allow non-interactive statically rendered pages (as far as I remember).

Re:React has grown beyond its original promise and it's caus... by benatkin on Thursday February 08, 2024 @09:28PM (#39310719)
> you can use it directly

Because of a poor design choice in an otherwise well designed platform (at least in the case of Deno).

Re:React has grown beyond its original promise and it's caus... by NathanaelRea on Thursday February 08, 2024 @09:35PM (#39310752)
Or Astro, and plugins for React/Tailwindcss/etc. Components are just nice to work with because of their modularity. Using the ergonomics "most web devs" are familiar with is just nice.
Re:React has grown beyond its original promise and it's caus... by mvdtnz on Thursday February 08, 2024 @11:18PM (#39311335)
JSX is a mediocre templating language that's missing a ton of features from more mature templating languages like Razor
Re:React has grown beyond its original promise and it's caus... by teaearlgraycold on Friday February 09, 2024 @01:32AM (#39312050)
I don’t know Razor but I agree. JSX could use an overhaul.
Re:React has grown beyond its original promise and it's caus... by forgotusername6 on Friday February 09, 2024 @02:25AM (#39312342)
What's it missing?
Re:React has grown beyond its original promise and it's caus... by richeyryan on Friday February 09, 2024 @04:04AM (#39312922)
I suspect they want better condition handling. Because JavaScript lacks a useful conditional expression beyond ternary expressions, condition handling in JSX generally uses boolean operators or ternary expressions. Suppose the conditional logic is in any way complex. In that case, your choice is to use nested ternary expressions, which can be hard to read or to somehow break the condition out of the JSX using a helper function or separate component so you can use if statements in a regular function context. SolidJS added conditional helpers to its JSX flavour to address this issue[1]. The React team seems ideologically opposed to the idea as it presumably moves JSX away from using only JavaScript for handling logic.

[1]https://www.solidjs.com/docs/latest/api#show

Re:React has grown beyond its original promise and it's caus... by tauchunfall on Friday February 09, 2024 @08:56AM (#39314866)
>I suspect they want better condition handling. Because JavaScript lacks a useful conditional expression beyond ternary expressions, condition handling in JSX generally uses boolean operators or ternary expressions.

If a condition in JSX gets too complex I normally extract a component-level function and call it from the JSX part of the component.

Re:React has grown beyond its original promise and it's caus... by _betty_ on Friday February 09, 2024 @04:17AM (#39313007)
knowing both i used to be frustrated by jsx's lack of support for plain if and for loops like razor has (eg map and the weird && syntax we general end up with)

eg ``` <ul> @foreach(var item in list) { <li>@item.name</li> } </ul> ```

of course this idea goes against jsx's implementation (as it's just nested functions) and paradigm of being html in plain javascript rather than an interpreted templating language.

some of the differences i really like (like being able to assign compoents to variables, pretty sure razor doesn't have anything like that).

Re:React has grown beyond its original promise and it's caus... by javcasas on Friday February 09, 2024 @10:15AM (#39315584)
The thing about jsx is that I don't have to learn the special syntax and rules that govern the @foreach construct.

jsx map accepts a js function which should return a jsx element. Can I use...? If it works in js, yes.

Re:React has grown beyond its original promise and it's caus... by _betty_ on Friday February 09, 2024 @02:54PM (#39319682)
Foreach in razor is just c# too, so it's not a language thing it's more what it transpiles to.
Re:React has grown beyond its original promise and it's caus... by pharmakom on Friday February 09, 2024 @02:26AM (#39312351)
Why do we need a templating language at all? Syntax is inferior to data.
Re:React has grown beyond its original promise and it's caus... by mvdtnz on Friday February 09, 2024 @03:56AM (#39312866)
How do you suggest we display that data in a web page?
Re:React has grown beyond its original promise and it's caus... by wonnage on Friday February 09, 2024 @04:03AM (#39312914)
It’s actually a fine language and these sorts of edgelord comments are the most annoying part of HN
Re:React has grown beyond its original promise and it's caus... by tauchunfall on Friday February 09, 2024 @09:01AM (#39314902)
That's true. It's missing "a ton of features" but the question is, if these missing features in the template language stop us from building correct and maintainable web applications. Having that said: We are fine with JSX.

Using Razor obviously did not stop Microsoft from building buggy web applications.

Re:React has grown beyond its original promise and it's caus... by moritzwarhier on Friday February 09, 2024 @09:15AM (#39315042)
JS is missing switch/match expressions, that's pretty much all IMO.

And I commend the maintainers of JSX for refusing to extend its syntax.

JSX can be learned in 15 minutes and it is a macro usually used to wrap React.createElement.

You could just as well swap your bundler plugin and use some other type of macro, e.g. sth like Mithril's m.

JSX is a very slim basic concept and I don't know a single gotcha except for the renamed attributes/props that are otherwise reserved keywords (htmlFor, className).

That you can use/see it as a templating language is just a part of its appeal.

I loathe having to use dedicated templating languages, having worked with Mustache and various PHP templating languages such as Blade and Twig.

Maybe "loathe" is a strong wors because most of the time it's easy and just works. But when it doesn't, debugging is a nightmare.

Escaping rules and questions like "what is code, what is a just an uninterpreted string" become unpredictable, and you have to learn useless baggage for each of them.

Same goes for all the JS DSLs using HTML attributes (Vue 2 "templates", which are actually not templates, etc). This is also what turns me off about htmx.

It'a great to throw together a specialized solution for one problem, but not great for libraries inventing unnecessary proprietary languages.

Re:React has grown beyond its original promise and it's caus... by Stoids on Friday February 09, 2024 @12:23PM (#39317487)
ts-pattern has been a decent band-aid for the lack of native pattern matching, but obviously has downsides that could be avoided if it was built into the language.

https://github.com/gvergnaud/ts-pattern

Re:React has grown beyond its original promise and it's caus... by tauchunfall on Friday February 09, 2024 @09:30AM (#39315167)
>don't know a single gotcha except for the renamed attributes/props that are otherwise reserved keywords (htmlFor, className).

This is related to `React.createElement`, I think. Preact does not have this problem. For client-heavy web applications I prefer React over Preact (not all libraries work well with Preact), but server-heavy web applications are fine with Preact.

Re:React has grown beyond its original promise and it's caus... by tauchunfall on Friday February 09, 2024 @09:34AM (#39315199)
>JSX is a mediocre templating language

You can also complain about JSON being a mediocre data format. But I think it's minimalism and compatibility with JS made it successful.

Re:React has grown beyond its original promise and it's caus... by lucsky on Friday February 09, 2024 @05:01PM (#39321029)
I had no idea what Razor was (I'm not a C# guy, I don't like to work on mediocre platforms... (see what I did here?)) so I read about it a lil' bit and could not find a single thing that it does that JSX cannot. Not one.
Re:React has grown beyond its original promise and it's caus... by mr_toad on Thursday February 08, 2024 @08:08PM (#39310107)
It actually is quite suitable for static pages where the content itself is quite dynamic (e.g. from a CMS or other database), especially when rendering repetitive data structures (e.g. lists of items). You use React on the server to render the contents on the fly as static html and serve that.
Re:React has grown beyond its original promise and it's caus... by brianhama on Thursday February 08, 2024 @10:06PM (#39310893)
What you are describing falls outside the definition of a static page. At least insofar as I’ve always understood.
Re:React has grown beyond its original promise and it's caus... by webprofusion on Thursday February 08, 2024 @08:10PM (#39310124)
True, but they're not a new developer, so maybe he's just saying what everyone thinks.
Re:React has grown beyond its original promise and it's caus... by OccamsMirror on Thursday February 08, 2024 @09:12PM (#39310611)
Can confirm the author (not me) has been doing web and system development, including React dev, for over a decade. His complaints are borne of his own frustrations.
Re:React has grown beyond its original promise and it's caus... by kaba0 on Friday February 09, 2024 @01:31AM (#39312044)
A decade of work experience doesn’t necessarily give them insightful insights. Especially if they don’t even know the core point of the topic at hand.
Re:React has grown beyond its original promise and it's caus... by lomase on Friday February 09, 2024 @03:50AM (#39312809)
Hackernews became reddit. Sad days.
Re:React has grown beyond its original promise and it's caus... by wiseowise on Friday February 09, 2024 @02:16AM (#39312287)
You’re trying to reduce someone’s 10 years of experience just because they have different opinion than you.
Re:React has grown beyond its original promise and it's caus... by kaba0 on Friday February 09, 2024 @02:19AM (#39312304)
They can have whatever opinion they want, but if they fail to grasp the basics of the topic, then that opinion should remain theirs alone.
Re:React has grown beyond its original promise and it's caus... by d1sxeyes on Friday February 09, 2024 @03:27AM (#39312681)
While I agree in principle that 10 years of experience can also mean '10 years of being a substandard developer in every way', what basics do you feel are missing here?
Re:React has grown beyond its original promise and it's caus... by treve on Thursday February 08, 2024 @10:28PM (#39311028)
Maybe it's a bit vague or don't have 'true insight', but I would still encourage anyone sharing their feelings, even if they're not expert level insights. React applications turning into a maintenance nightmare and the meta changing under your feet is a common sentiment and I think it's helpful if more people talk about this.

One issue in the frontend space is that React has been the default no-questions-asked choice, but my personal vague, no-true-insight feelings are also that you need a technically very proficient team to avoid it turning into a maintenance nightmare.

Many people work for SMBs, and it feels like there's not a great golden path currently for frontend. Doing a something simpler somehow feels like a bigger risk to the people I chat with.

Re:React has grown beyond its original promise and it's caus... by danjac on Friday February 09, 2024 @02:30AM (#39312372)
I have seen so many React code bases that are the polar opposite to "clean, manageable code" that I would strongly disagree with this premise.

That's not to say React is to blame, per se, but good code is the result of good developer practices rather than some framework.

Re:React has grown beyond its original promise and it's caus... by vjerancrnjak on Friday February 09, 2024 @03:21AM (#39312651)
A good question is "What is interactive?" Many "interactive" things can be done just with CSS and HTML.

* a list of elements you can select and delete/bulk-edit is feasible with <form>

* any kind of form with input

* hide/show toggle

* tabs

* accordions

Many single page apps aren't really interactive or require minimal JS.

Currently, we're doing things in JS (like forms, pages, tabs, virtualized lists & tree views, hovers, even buttons with JS click handlers) just because our server does not render HTML.

Re:React has grown beyond its original promise and it's caus... by wonnage on Friday February 09, 2024 @03:58AM (#39312878)
It’s true that a lot of simple apps could just be written using direct DOM manipulation, but you basically write yourself into a corner. There’s no gradual transition from that to any framework, you just have to rewrite your app

Might as well just start with the least common denominator that everyone knows and is easily hired for

Re:React has grown beyond its original promise and it's caus... by alexanderchr on Friday February 09, 2024 @06:30AM (#39313768)
Yeah especially things like complicated forms can get really hairy if you try to implement them by direct DOM manipulation. Things like fields being shown conditionally based on the value of other fields, data being fetched in the middle of form (depending on field values), stupid complicated validations etc.
Re:React has grown beyond its original promise and it's caus... by GlenTheEskimo on Friday February 09, 2024 @10:32AM (#39315779)
I made a paint app with jQuery, and thought it would be a good idea to refactor to React so I could run it on a Next js server and add some multi user support, with later plans of refactoring that to a React native app.

Completely painted into a corner, I gave up after about six hours of trying to get my event listeners to work with React.

It's a shame, because there's so much server side stuff I could be doing right out of the box with Next, but now I basically need to choose a completely different architecture from the one I want because I thought it would be easier to use jQuery.

In all fairness, direct DOM manipulation works a lot better than React for the original app, but now I have to keep DOM state in sync with my server, which is a whole other challenge that React solves quite nicely.

Re:React has grown beyond its original promise and it's caus... by pcthrowaway on Friday February 09, 2024 @10:49AM (#39316002)
I'd definitely recommend giving svelte a try, might be fun to integrate some of their built-in animations/transitions with a paint-like app also
Re:React has grown beyond its original promise and it's caus... by greenie_beans on Friday February 09, 2024 @10:36AM (#39315821)
lots of folks bash react without actually knowing how to use it.