Live data from Hacker News

Does anybody like React?

jsx.lol

301–310 of 353 posts

Re: Does anybody like React?

#301
post #8

I like React. And I have seriously tried the HTMX/Hotwire camp. I wanted to make a back button use browser APIs to go back if the coming from the inbox, just link to the inbox otherwise to preserve scrolling. I had to wire the actions from the html to call the function that goes back, then in my controller determine the previous page and send the JS enabled back button or the hard link. My logic was spread out over 3…

Isn't the best way to solve the back button question to not be so damned complicated and just make certain that only things which you want to go back to ends up in the history? The whole framing of the problem just screams "structure your thing better and it won't be a problem to solve".

Re-read it. We needed to preserve scroll position when you went back. If you just linked back to the inbox it would kick you to the top of the screen.

Re: Does anybody like React?

#302
post #30

Earlier quoted context omitted.

I was a big Sevelte fan. After writing a sizeable application in Sevelte I realized that React is superior in every way overall speaking and at least you're writing 100% pure JavaScript directly. Or Typescript. Plus the ecosystem. It's huge. Nothing comes closer.

> 100% pure JavaScript directly How did the React community convince so many people of this falsehood? Do that many people just not know what javascript is? It baffles me that one could look at JSX and be like, “that right there is vanilla javascript”.

History is important here. React came at a time when so many frameworks used custom template libraries for variable binding, looping, conditionals, etc. Usually it was some HTML/XML-like markup language.

Re: Does anybody like React?

#303
post #8

I like React. And I have seriously tried the HTMX/Hotwire camp. I wanted to make a back button use browser APIs to go back if the coming from the inbox, just link to the inbox otherwise to preserve scrolling. I had to wire the actions from the html to call the function that goes back, then in my controller determine the previous page and send the JS enabled back button or the hard link. My logic was spread out over 3…

My advice would be to only use HTMX for data state related operations. For something like an intelligent back button, unless it depends on resource state do not use the backend to calculate it. The recommended htmx way would be to hook up an onclick button to inline js or if you dislike that, a function called goBackOrInbox. It can then be something like: function goBackOrInbox() { if (document.referrer) { const path…

I never thought about doing that. Thank you.

Re: Does anybody like React?

#304

I really like Svelte and have been using SvelteKit for more complex apps. I've found it to be a great improvement over many cases where I would have used React before. Svelte feels much easier to learn for someone who already knows the basics of web development, HTML, CSS, and JavaScript. But nowadays I often see people start learning web development by learning React, which feels a bit backwards. Personally I have b…

I also always reach for Svelte + SvelteKit (Using Kit for simple apps can be overkill, but it's nice to have when things get complex unexpectedly).

> But nowadays I often see people start learning web development by learning React, which feels a bit backwards.

I think Svelte prevents this nicely by treating HTML as the mother language. If someone started web dev with Svelte(Kit), they would probably learn more about the fundamentals than they would with React.

Re: Does anybody like React?

#306
post #250

Earlier quoted context omitted.

Implementing spreadsheets with fine-grained reactivity is basically cheating.

Haha, that was part of the reason we originally went down this route. In practice, as soon as you want to implement spills, you lose a lot of the benefits because the contents of a spill can depend on any other cell and affect almost any other cell, and you need to evaluate the spill to figure out which cells are relevant. In the end, we rewrote the spreadsheet engine to use a different mechanism that was simpler and…

This tracks exactly my experience described in sibling comment https://news.ycombinator.com/item?id=48275892

Re: Does anybody like React?

#308

Earlier quoted context omitted.

Interesting that you still stand by that, even after Apple moved to the exact same model with Swift UI. Narrowmindedly worrying about syntactical differences is contributing nothing to the conversation. The point is relinquishing control of state to the framework (be it via props, hooks or @State), and drawing the UI as a pure representation of whatever the framework tells you. Hence ui = f(state). This gets you a me…

Interesting that you would think Apple introducing Swift UI would have any bearing on the correctness of that blog post. Why do you think it would? Did you misread my post as "ha ha, Apple does it differently and therefore react is wrong"? If so, you certainly misread it a lot, and you have the wrong person. I have tons of posts about Apple getting things wrong. Anyway, did you miss the following part? I also think t…

Maybe it's a me-thing, but when I see the creators of a system I trust basically deprecate it, then I try to re-evaluate my viewpoint. Also, when I read the post a few years back, I honestly thought that it must have been a product of its time.

> Every UI is always some mapping of the state.

Sure, but it previously wasn't described as such. It was described as a list of imperative operations "if x do that" (unless the developer just gave up and had a giant refreshEverything() function). IIRC, at the time, MVC had a common problem of controller bloat, precisely because it was trying to perform the reconciliation between view and model imperatively rather than simply describing it as a function. MVVM solved this partially with data-binding, but depending on the framework, you still had lackluster handling of derived state inside the view-model.

> What does "pure representation" mean to you?

I mean that, the render function of the component is a 100% pure function of the state that the framework injects. By "render function" I mean everything except the statements beginning with `use...`. Those are just React's syntax for defining the component. Another framework such as SwiftUI might have defined them outside the function.

> But can you elaborate the specific advantages you believe the react approach gives us over, say, MVC?

There are so many resources on this, so I don't know what I can say to convince you, but I'll try:

* The Compiler. Regardless of whether you think it’s self-inflicted complexity (I don’t), functional patterns generally are easier to statically analyze and transform.

* Transitions, concurrent rendering, suspense, & time-slicing. All of these are possible by rendering components with outdated state. A low priority update may trigger a loading state and defer its commit. Meanwhile, high priority updates can continue to work as usual. In the past ~2 years, this is easily where I've seen the most UX & DX gains in frontend.

* Most importantly: readability. Even if components are only 90% pure, I still see side-effects and state clearly marked. Even in MVVM, I've seen so much spaghetti from my coworkers. In React & post-React frameworks, when debugging a component, I have a much narrower range of things I need to check. For example, I don't have to worry that an object I'm reading from is being mutated by a component on a completely different route.

Overall, the reason why this post rubs me the wrong way, is that you took a theoretical design document, misunderstood it for the actual, practical implementation and snarked at the authors for not going with the "obviously correct" solution of OOP. Not seeing the bigger picture in 2018 is understandable, but now it's... interesting.

Re: Does anybody like React?

#309
post #156

Earlier quoted context omitted.

"These burgers are pure beef! Obviously what people mean is that beef is one of the ingredients. Everyone knows that the plastic is added in, there's no conspiracy here"

It's like arguing the moon and sun are the same size because they look the same size when looking at the sky. A hamburger with added plastic is essentially a hamburger. A hamburger made out of plastic that resembles beef is not.

I don't understand how you can interpret "pure means not adding in stuff to water it down" as "everything that's vaguely similar is the same", because from my perspective that's exactly what the parent comment I responded to is doing

Re: Does anybody like React?

#310

What's interesting to me is that it seems a lot of people got burned by AngularJs (Angular 1) and now swear off Angular as a whole. Like many, I came from pre-SPA days -> AngularJs -> Angular 2 -> Modern Angular. I tried react a few times, plus React Native but found it hard. I wasn't good with a slightly different render-syntax (whereas Angular uses HTML) and every project I was on was wildly different from each oth…

For what it is worth, I missed AngularJS/Angular 1 and managed to use Aurelia to avoid several versions of Angular 2+. When I did get eventually pressured into working on Angular it was a nightmare for several reasons. One of them was I got hugely burnt by Zone.js. Angular is finally doing something about Zone.js years after my warning. (Though it took Signals to push them to do it, which is another rant because Signals are just dumber Observables and Angular already has an RxJS dependency.)

> (whereas Angular uses HTML)

Angular has as complex a template language as any other major framework. The fact that it uses .html files is a convenient lie to make it seem like it is "just HTML". Its template compiler is a far more complex beast than JSX. (And it doesn't have anything like half the type safety of TSX.)

Post reply on HN