Live data from Hacker News

React is holding me hostage

emnudge.dev

521–530 of 553 posts

Re: React is holding me hostage

#521

Earlier quoted context omitted.

Well, don't use those. Pure React is enough 95% of the time, and then an additional 4.9% can be handled with jotai in a couple of places. React + GraphQL + jotai is my preferred stack

> Don't use those...then an additional 4.9% can be handled with jotai... Needing Jotai on top of React's defacto state management is the issue. TFA talks about an ecosystem of libraries that attempt to fix React's shortcomings. Pure React does have undeniable shortcomings like proper, non-brittle routing.

They intentionally didn't provided that to let the ecosystem explore different solutions.

Re: React is holding me hostage

#522
post #471

Earlier quoted context omitted.

Can you clarify what you mean here? What state is in DOM? Do you mean the state inherent in input elements? What timing hacks are you talking about?

The first file I looked into was the combo box. This is what I consider to be a timing hack: private onDropDownMouseOver(ev: MouseEvent): void { if ((new Date()).getTime() Some event stores the time it has been fired, and this method checks that it has not been long since the firing. With react, which item has the highlight would have to explicitly be in the state and completely remove the need to do this optimizatio…

The timing hack is a workaround for a browser bug. The exact same hack would be required in React as well. What is this browser bug I speak of? Browsers send a spurious "hover" event when you stop scrolling, so that the item under mouse can be highlighted. This can cause problems in some cases.

> Now any element in your page has the power to modify this component’s logic by modifying the DOM

If some part of your application intentionally does something wrong, it can break your application whether it is React or some other tech. In this particular example, if you prefer, you can have a member variable to keep track of whether the dropdown is visible or not. Still no need for React.

As you can see, none of the complexity of React is necessary. No need for hooks, useEffect, useState, useMemo and all that crap.

Re: React is holding me hostage

#523
post #340

I'm still a React guy. I've also worked with Angular and Vue and toyed with Svelte. People tend to compare these frameworks on things that don't matter - often it's performance. We used to compare React performance to AngularJs performance too, which was meaningless. VDom is nice. Reactivity in signals is nice. Limiting rerenders is nice. But I choose frameworks because of developer ergonomics. The killer feature for…

What’s the alternative to useEffect? I need it very often.

you could try XState events, see David's "Goodbye useEffect" talk: https://www.youtube.com/watch?v=bGzanfKVFeU

or you could try the newfound craze: signals.

Re: React is holding me hostage

#524

I'm still a React guy. I've also worked with Angular and Vue and toyed with Svelte. People tend to compare these frameworks on things that don't matter - often it's performance. We used to compare React performance to AngularJs performance too, which was meaningless. VDom is nice. Reactivity in signals is nice. Limiting rerenders is nice. But I choose frameworks because of developer ergonomics. The killer feature for…

JSX is overrated. Why copy HTML, which is a pain to write? I much prefer regular old function calls. Or even s-expressions!

Re: React is holding me hostage

#525
post #471

Earlier quoted context omitted.

The first file I looked into was the combo box. This is what I consider to be a timing hack: private onDropDownMouseOver(ev: MouseEvent): void { if ((new Date()).getTime() Some event stores the time it has been fired, and this method checks that it has not been long since the firing. With react, which item has the highlight would have to explicitly be in the state and completely remove the need to do this optimizatio…

The timing hack is a workaround for a browser bug. The exact same hack would be required in React as well. What is this browser bug I speak of? Browsers send a spurious "hover" event when you stop scrolling, so that the item under mouse can be highlighted. This can cause problems in some cases. > Now any element in your page has the power to modify this component’s logic by modifying the DOM If some part of your appl…

Would it, though? Keyboard event sets highlighted item key/id; scroll event pops up, sets the highlighted item again, then react does not do an additional render because the state has not changed since the keyboard event.

The code does not have any complexities of hooks (which are just a javascript approximation of do notation, I don’t believe it is that complex), but what it does have is the requirement to write down all of your mutations correctly, where every “down” is an exact opposite of the “up” and does not leave any artifacts—with no way of formally checking. At least for myself, I think that level of discipline is unreasonably high so I tend to prefer stricter typed functional solutions where the view is composed purely from the state

Re: React is holding me hostage

#526
post #262

Earlier quoted context omitted.

> Templates are a no go for me. I use them for blogs or static websites, but applications are easier to make and maintain with actual javascript. Could you expand on this. You assert that "applications" are easier to maintain with JS, but blogs are not? Are you defining "application" here as something with dynamic and interactive content? Also, why is it easier to "make and maintain"? I'm not necessarily disagreeing,…

The way I look at it - the majority of value with blogs and static website is content. Hence the majority of change is of content. For apps the majority of value is functionality and that's where a lot of changes happen. The main problem of maintenance happens where there is the most change - in JSX programming (I.E. functionality) is a first class citizen and it lends it easier to change. With templates content is m…

Thanks for the explanation. Makes sense.

Re: React is holding me hostage

#527

Earlier quoted context omitted.

I'm not seeing React being used, though, just TSX/JSX? All the view and state updating is being done manually, but it looks fairly well-organised. There are small optimisations like debouncing onInput with a timeout (avoiding rapid re-rendering/ react ing to every character typed): https://github.com/wisercoder/eureka/blob/master/webapp/Clie... Is this really much more complicated to implement than the equivalent imp…

I think they’re referring to how Reacts mental model is to wipe the page and rerender. The earliest versions basically did that, and then they started diffing and applying the diff.

They're referring to a specific bit of code in that Eureka repo that sets innerHtml = "" and then does .appendChild(). They just apparently didn't notice that the code doesn't use React at all (and is meant to demonstrate the use of vanilla modern JS without React).

Re: React is holding me hostage

#528
post #70

Earlier quoted context omitted.

None of that is true in React hooks. The negative sentiment towards hooks that you see here is because it is weird and complicated. Want to see how much simpler code can get when you code without React or any such fat frameworks? Take a look: https://github.com/wisercoder/eureka/tree/master/webapp/Clie... You just need to know JavaScript, HTML and CSS, not much else. The code is simple, and yet maintainable. No need…

https://github.com/wisercoder/eureka/blob/master/webapp/Clie... I love how you do React. I mean, what's more react-y than blanking the page then appending HTML? I'm gonna call that Rejqueryact, because it's jQuery inside React.

There is no jQuery or React being used. You can use TSX without using React. See https://github.com/wisercoder/uibuilder

Re: React is holding me hostage

#529
post #502

Earlier quoted context omitted.

> The solution really is to create your own language so you can express the problem you are solving in the terms of the problem and not the underlying language/platform/hardware. That's what Elm is about. I've talked about it in another thread, so I won't repeat myself here.

I had heard of it, but never checked until you mentioned it in this context. It seems that Elm is an entirely new language written atop JS (or maybe not, and targets JS?). A DSL. DSLs also usually are an incomplete solution. Unless they themselves allow adhoc language creation using the DSL as a base. Common Lisp with its macros allows writing DSLs quite off-handedly as you program. You grow your program and language…

Elm is an entirely new language that compiles to JS, it is not a DSL.

Re: React is holding me hostage

#530
post #70

Earlier quoted context omitted.

None of that is true in React hooks. The negative sentiment towards hooks that you see here is because it is weird and complicated. Want to see how much simpler code can get when you code without React or any such fat frameworks? Take a look: https://github.com/wisercoder/eureka/tree/master/webapp/Clie... You just need to know JavaScript, HTML and CSS, not much else. The code is simple, and yet maintainable. No need…

We’re coming at this from different mental models. The code you linked is what React helped me get away from. There’s multiple files in different folders for one screen. It’s hard to see how it composes, which is a useful boundary as it lets me know in the scope of that part of the UI. UI is _hard_. There’s complexity that needs to go somewhere, and I’m one of those who prefer to push as much if it that isn’t busines…

It is idiomatic JavaScript. If you learned Java at the university you'll immediately be comfortable with the code. Now consider React with hooks. It is neither OOP nor functional and it looks alien to anyone who knows idiomatic Java or JavaScript. Would you recommend a youngster learning programming to learn React? I wouldn't, because it is so frankenstein. This article makes that point better than I can: https://medium.com/codex/can-we-all-just-admit-react-hooks-w...
Post reply on HN