Live data from Hacker News

React I love you, but you're bringing me down

marmelab.com

281–290 of 574 posts

Re: React I love you, but you're bringing me down

#281

> Dear React.js, > We've been together for almost 10 years. We've come a long way. But things are getting out of hand. We need to talk. > It's embarrassing, I know. Nobody wants to have that conversation. So instead, I'll say it in songs. Am I the only that finds this open letter format extremely cringey? I almost didn't want to read the article after that intro. The content was excellent otherwise.

By the same extension, would you consider your comment worthy of the same classification of "cringey"? How you feel about the delivery is not relevant to the topic, and if you had opted not read to it, it would not be the person in the arena that would be at a loss because of it.

> By the same extension, would you consider your comment worthy of the same classification of "cringey"?

No, but I think your comment falls squarely in that category.

Re: React I love you, but you're bringing me down

#282

Earlier quoted context omitted.

They mostly encourage bad practice by design and people do what these tools give an affordance for which is why the results are broken.

People can write bad things in every language. "It takes a lot of skill to write Java in any language." is a pithy quote for a reason. The issue is usually frontend pedagogy or the lack of it. Maybe things have changed but when I graduated undergrad CS in 2017 the extent of frontend being taught in my school by professors was "hand write some HTML, maybe some PHP if you're lucky". I've never met anyone who learned fr…

> Maybe things have changed but when I graduated undergrad CS in 2017 the extent of frontend being taught in my school by professors was "hand write some HTML, maybe some PHP if you're lucky"

And rightly so, because frontend web development is not Computer Science.

Re: React I love you, but you're bringing me down

#283
post #265

Earlier quoted context omitted.

Oh wow. I was always skeptical of "concurrent React" (the scheduler approach seemed insane to me), but this seems like such a basic issue, I'm surprised this ever shipped in any form.

Yeah, it seems suss AF. IIRC it also only bales out during the DOM update phase; not during the calls to render() and then reconciliation(?). And if it bales out, it has to re-render everything again when it comes back to make sure the state is consistent(nothing has changed). The exact details are fuzzy and that may be incorrect but the impression I came away with after reading an engineering post about the deets wa…

> it also only bales out during the DOM update phase; not during the calls to render() and then reconciliation(?)

It's exactly the opposite.

React splits work into two parts: the "render phase", where it loops over components and asks them to describe the UI they want (returning JSX/elements); and the "commit phase", where it has determined the changes that _need_ to happen to the DOM.

The render phase is the part that can be split into many pieces. React can render a few components, see that 5ms has elapsed, and yield to the browser, then pick up where it left off and render a few more components. Or, it could render some components, pause, see a high-priority user event happen like typing into an input, and set aside the partially completed render pass to go re-render based on the input update. Then, after the input render is done, it can pick up where it left off with the other partial render, "rebase" it onto the current UI contents, and continue from there.

The commit phase is _always_ synchronous, start to end, and that's where the actual DOM updates are applied.

Some more details:

- https://blog.isquaredsoftware.com/2020/05/blogged-answers-a-...

- https://github.com/reactwg/react-18/discussions/55

- https://reactjs.org/blog/2022/03/29/react-v18.html#what-is-c...

Re: React I love you, but you're bringing me down

#284

I must be the only person in the world who likes class components in React. Sure, it's often overkill and a functional component does the same thing with less code. Use a functional component in these cases. But if you're doing something more complicated then stop treating class components like the fucking devil. They have their place.

[deleted]

Re: React I love you, but you're bringing me down

#285

Earlier quoted context omitted.

They mostly encourage bad practice by design and people do what these tools give an affordance for which is why the results are broken.

People can write bad things in every language. "It takes a lot of skill to write Java in any language." is a pithy quote for a reason. The issue is usually frontend pedagogy or the lack of it. Maybe things have changed but when I graduated undergrad CS in 2017 the extent of frontend being taught in my school by professors was "hand write some HTML, maybe some PHP if you're lucky". I've never met anyone who learned fr…

> Maybe things have changed but when I graduated undergrad CS in 2017 the extent of frontend being taught in my school by professors was "hand write some HTML, maybe some PHP if you're lucky"

Here's a secret nobody told you: You don't need to learn frontend specifics. All the same lessons from business software engineering apply.

I not-graduated comp sci in 2012 and have been building webapps since before jQuery was cool. It's nothing special. The biggest problems are always the same: data and domain modeling, managing complexity, teamwork, and state consistency.

If your comp sci degree didn't teach you how to apply solutions to those problems in any context – frontend, backend, iOS, firmware, desktop app, Android, or data pipeline – then it was a worthless degree and you should get your money back. The point of comp sci is to learn about the ideas behind the scenes, not about specific frameworks.

Re: React I love you, but you're bringing me down

#286

Props to marmelab's react-admin, and the ng-admin that preceded it. If you need CRUD without adopting some "low code" platform and its half dozen containers full of weird databases, react-admin is a fine choice. I have wondered what svelte-admin would look like.

React Admin works really well with Hasura (there's an adapter) for whipping up dashboard apps.

Re: React I love you, but you're bringing me down

#287

I must be the only person in the world who likes class components in React. Sure, it's often overkill and a functional component does the same thing with less code. Use a functional component in these cases. But if you're doing something more complicated then stop treating class components like the fucking devil. They have their place.

Hooks are a natural progression from class components, class components seem more straightforward with all the willMount beforeMount etc. but they trick you into visualizing your component in different states of mounted/rendered/etc. That goes against what React wants to be at its core, which is totally immutable and pure, it isn't mounted or pre/post-render it looks the same whether it is the first render or the 100…

[deleted]

Re: React I love you, but you're bringing me down

#288

Earlier quoted context omitted.

People can write bad things in every language. "It takes a lot of skill to write Java in any language." is a pithy quote for a reason. The issue is usually frontend pedagogy or the lack of it. Maybe things have changed but when I graduated undergrad CS in 2017 the extent of frontend being taught in my school by professors was "hand write some HTML, maybe some PHP if you're lucky". I've never met anyone who learned fr…

woah woah hold on there young one This isn't that. My hostile working definition of a framework is something that . breaks core assumptions about a language or system . limits what a user is permitted to do . increases complexities by adding new abstractions . has non-specific specifications by using unclear and imprecise language At the end you are hardly writing software. Instead you're deep into a world of new abs…

This is cynical as heck, but a good read. Do you have any plans to publish the larger document?

Re: React I love you, but you're bringing me down

#289
post #148

Earlier quoted context omitted.

Heh. Arguably JS itself "invented a half-baked, partial re-implementation of objects/classes"... _in their class implementation_. God it drives me nuts that the language will allow you to spread a class into an object and it will take the properties but not the methods.

Exactly! If the Javascript implementation was better, React probably never would have had to come up with Hooks in the first place.

You can solve the problem Hooks purported to solve in plain, idiomatic JavaScript with classes[0]

[0]https://raganwald.com/2016/07/20/prefer-composition-to-inher...

Re: React I love you, but you're bringing me down

#290

Earlier quoted context omitted.

Mithril or Svelte should be all you need. If you're coming from React, I'd recommend trying Mithril first. I've been using it heavily for 5 years now and I'll likely stick with it for at least another 15. Mithril is reactive out of the box, and just works. It smokes React in every category, but still has an optional JSX integration if that's what you're comfortable with. https://mithril.js.org/ https://svelte.dev/

I was excited about Svelte, but now Astro JS is my favorite.

Those tools are not mutually exclusive. Astro is not a component UI library.
Post reply on HN