Live data from Hacker News

Does anybody like React?

jsx.lol

321–330 of 353 posts

Re: Does anybody like React?

#321

As someone who lived through all major waves of JS for the last ~16 years, I do love react, in a sense: React is the worst JS framework except for all the others we've tried. I'd take React over the Angular 1 days any time. I'd take Angular 1's full-bodied MVC over the "build it yourself from scratch every time" approach of Backbone. I'd take Backbone's minimal MVC structure over the classic JQuery Soup architecture.…

But why over vue? My biggest frustration has been how vue ends up moving in the direction of react. The original component architecture with the html template, JavaScript state and css styles in vue was so nice. Even the data fetching a url in the component was so intuitive.

Is Vue still magic, or can you actually write normal typescript?

Re: Does anybody like React?

#322

One of the talks I really enjoyed is https://www.youtube.com/watch?v=h9SDuTSy7ps . In my experience, React's architecture is really good and lends itself quite well to making large applications. Unfortunately, React's biggest problem is that it forces you into the JS/TS ecosystem, which is, without a doubt in my mind, a compilation target rather than a system I wish to interact with natively. I'm happy with Elm -- th…

I like TEA but don't fully grasp how it scales for apps that may have reusable components or sufficiently complex pages. Is there an agreed-upon way(s) to deal with this? I know state is a big NO so it seems a bit at odds, but also does this essentially mean all Elm apps are just a global Redux and React app with no effects? Curious about more details to what you enjoy and how you like to work in Elm. Links also perf…

In my experience, the biggest problem in Elm is how unintuitive TEA's docs are. In some ways, Elm really feels like Haskell -- you want to avoid creating "stateful" modules and you prefer stateless modules.

For example, https://harmont.dev's app (landing page is not Elm) has a component to render a pipeline graph called DagGraph. In React, you'd do something like

  function DagGraph() {
    const steps = useState([]);
    const selectedJobIdx = useState(null);
    return ...;
  }
In elm, I lift this up (I will keep using React syntax for the sake of wider-audience readability)

  function DagGraph({ steps, selectedJobIdx } : IDagGraphModel) {
    return ...;
  }
This allows for better testability of the graph view. The parent then injects the model

  function PipelinePage({ graphMode, selectedPipeline }: IPipelineModel) {
    return (
      graphMode === GraphMode.DagView
        ? 
        : 
     );
  }
Now -- we need to bubble up the selected pipeline index based on when the user clicks a node in the DAG view. I personally prefer to do this completely orthogonally to the view rendering pipeline (which remains mostly pure). I create a new model, and define the message relationships to it:

  namespace PipelineState {
    interface Model {
      steps: Step[];
      selectedStep: number | null;
    };

    interface ISelectStepMessage { stepIdx: number };
    interface IUnselectStepMessage;

    type Message = ISelectStepMessage | IUnselectStepMessage;

    function update(m: Model, msg: Message): Model { return...; }
  }

  // main model
  interface Model {
    pipeline: PipelineState.Model,
  }

  type Message = PipelineState.Message | SomeOtherMessage | ...;

  function update(m: Model, msg: Message): Model {
    switch (msg) {
      case PipelineState.Message as msg:
        return update(m, msg);
      ...
    }
  }
And this seems to work quite well. Personally, I really like this architecture, because it enables me to think about state and UI separately. One of the really big gripes I have with React is how most components end up with `useEffect` and `useState`, and then immediately become untestable. Elm literally doesn't allow for that.

At the end of the day, there's a trade-off -- my logic is no longer localized to the "component" relevant to rendering the pipeline DAG. I never have one file open editing Elm code, but I'm a vim user so it doesn't bother me. In some ways, semantically, I think it makes sense to split the "state backend" of your UI from your UI, in my opinion.

Most of my app states are represented as state machines (coming from embedded this is quite natural) and UI is represented as pure transformations of that state.

With Elm, it really feels like you reason about state and UI separately, and I actually prefer that, both for testability and that's just how my brain works.

Re: Does anybody like React?

#323

One of the talks I really enjoyed is https://www.youtube.com/watch?v=h9SDuTSy7ps . In my experience, React's architecture is really good and lends itself quite well to making large applications. Unfortunately, React's biggest problem is that it forces you into the JS/TS ecosystem, which is, without a doubt in my mind, a compilation target rather than a system I wish to interact with natively. I'm happy with Elm -- th…

Elm is essentially dead in my experience. I'd rather stick with React and TypeScript with libraries that continue to work. And there have been attempts at making TypeScript natively compilable too.

I wouldn't call Elm dead. Development has frozen, this is true, but X11's development was frozen and it still powered so much for decades. This is actually super common in the Clojure community -- many libraries look dead, but they're just feature-complete and FP is usually quite bug-free, when implemented correctly.

Totally recognize and agree with the lack of libraries -- that's really Elm's weakest side.

Re: Does anybody like React?

#324

More than React, I'm interested in the question of how to best write UI through code, in general. Even though I'm a fan of React, and use it for practically every web application I build, my biggest and most obvious issue has been that writing UIs through React doesn't feel as natural as, say, writing command line tools in Go, or live/realtime apps in Elixir. Some languages just feel incredibly natural and frictionle…

I feel similarly. I really liked React when it came out because compared to the alternatives at the time, it just felt perfect.

I still prefer it over almost everything, including Svelte, Vue and Solid. But I have started using Crank (https://crank.js.org/) which seems a step closer to where I want to end up. However, I have so far only used it for toy projects so I can't speak to how well it will scale, both in terms of performance and DX.

Re: Does anybody like React?

#325

Earlier quoted context omitted.

Elm is essentially dead in my experience. I'd rather stick with React and TypeScript with libraries that continue to work. And there have been attempts at making TypeScript natively compilable too.

I wouldn't call Elm dead. Development has frozen, this is true, but X11's development was frozen and it still powered so much for decades. This is actually super common in the Clojure community -- many libraries look dead, but they're just feature-complete and FP is usually quite bug-free, when implemented correctly. Totally recognize and agree with the lack of libraries -- that's really Elm's weakest side.

The issue is Elm isn't feature complete though, at least not what its founder's vision is supposed to be, and they also aren't trying to improve it while berating users. This post [0] is as true as it ever was, including my comment there.

[0] https://news.ycombinator.com/item?id=43069475

Re: Does anybody like React?

#326

Earlier quoted context omitted.

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 th…

> but when I see the creators of a system I trust basically deprecate it,

What makes you think I trust Apple? So yes, that's very much a "you thing".

And SwiftUI is laughably bad. And my very early criticisms of Swift, for example, have panned out precisely as I predicted.

> > Every UI is always some mapping of the state.

> but it previously wasn't described as such.

Yes it was. Except this was seen as the obvious given that it is. Because, once again, a UI that is not a function (mapping) of the model is not a UI.

"In Smalltalk-80, a view is just a visual representation of a model" -- https://en.wikipedia.org/wiki/Model–view–controller#View

> IIRC, at the time, MVC had a common problem of controller bloat,

Nope. Non-MVC implementations had the problem of controller bloat, because they didn't actually implement MVC.

> the render function of the component is a 100% pure function of the state that the framework injects.

Except, as I've correctly pointed out: it's not.

[Advantages]

None of this is in any way specific ("The compiler". Seriously?) or clearly an advantage that can be tied to this type of framework. So yes: you're not even close to convincing me. Because there's no "there" there.

> 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

You misunderstood the post. Completely. The document claims "pure function". This is laughably false. The question is what is left when you remove "pure" from "pure function". And the answer to that is: nothing.

That doesn't mean there are no benefits, but the benefits cannot be "what you get from being a 100% pure function", because it ain't.

Just like the benefit of butter can't be "it's 100% fat free". Because it ain't.

And if you keep insisting that those are the benefits, then I don't know how to help you.

And again, it doesn't mean there are no benefits, but they are both smaller than and quite different from what you claim. And with the benefit being fairly small, the other question is what the cost is of pretending this is so when it is not. And the answer is: pretty high.

And it's funny that on the one hand you go with the same "well, you're taking the "100% pure" thing too literally", when just a few lines above, you yourself made "100% pure function" the defining characteristic.

So which is it? Make up your mind. It appears to be Schröding-important.

Any UI that actually is a UI is some sort of function of the state. Otherwise it is not a UI but random graphics and/or decoration.

Re: Does anybody like React?

#327
post #46

ELM forever! I like ELM because the core is extremely small. You just have to remember the model, the update function and the message type. That is it. React on the other hand makes you remember a million conventions and patterns and api like useEffect, useState, hooks.

Mint? https://mint-lang.com/

Re: Does anybody like React?

#328

As someone who lived through all major waves of JS for the last ~16 years, I do love react, in a sense: React is the worst JS framework except for all the others we've tried. I'd take React over the Angular 1 days any time. I'd take Angular 1's full-bodied MVC over the "build it yourself from scratch every time" approach of Backbone. I'd take Backbone's minimal MVC structure over the classic JQuery Soup architecture.…

I enjoy React and I’d take it over all of those other things. I wouldn’t take React over htmx/data-star and server rendering if that’s all I needed, and even if I had a couple of pages that needed a little bit more.

Re: Does anybody like React?

#329
Here are the things I don't like in React. Keep in mind that React is a framework to draw interactive HTML on screen, not for some crazy programming.

1. Over-reliance on complex concepts and terminology. Let's compare with Vue: `useEffect` vs `watch`, `useMemo` vs `computed`.

2. This useless "clever" stuff also slips beyond terminology: many years ago, Redux was considered the go-to state manager, and it required writing a lot of code across multiple files even for incrementing a number, because its author liked a lot of clever CS concepts. VueX at the same time allowed just to increment that number. Thankfully, nowadays, the React ecosystem is full of sane state managers.

3. React ships without any tools to work with CSS. That said there is no chance you would use React without CSS.

4. React doesn't bother optimizing anything for you. You need to know how and when to properly use or not use these clever `useEffect` and `useMemo`. There is a lot of stuff to know, and there are a lot of folk legends about optimizing React. This is while rerendering is its main purpose. In Vue, the framework makes you always use its tools, and does most of the optimizations inside them. I never thought about manually optimizing a Vue app.

5. The folk legends. React API and the "correct way" to write React radically changed so many times, so it is very hard to understand what is still true today and what is not.

All of that can be summarized into one – React is overly focused on ideas, computer science, and being high-level. And not very focused on actually making drawing interactive HTML on screen simple.

I do write a lot of React, Vue, and Svelte. And when I write React I always need to think about stuff, of which I never would think about with Vue and Svelte, because they already took care about it. And performance wise they are on par.

btw, I wrote a related post some time ago https://www.brachkow.com/notes/what-i-like-in-vue/

Re: Does anybody like React?

#330
I do. Though I avoid using it as much as possible because it's an overkill for practically everything like any other modern frontend framework. It's a Computer Science thing used where it should not. We really don't need to keep the state of the entire dom. It sounds great in CS, but in the real world, it ends up in bloat. Few websites other than social network sites, financial/trading sites etc ever need to update every corner of the page. The majority of the web can just do with having 1-2 interactive, auto-updating zones on each page. That's why we are going back to where we were 15-20 years ago with things like the 'islands architecture'...
Post reply on HN