Live data from Hacker News

React to LiveView for Performance [audio]

podcast.thinkingelixir.com

31–40 of 48 posts

Re: React to LiveView for Performance [audio]

#31
post #15

Whenever I see examples of LiveView being used it all works seamlessly but the UI always looks very simple, like basic forms, links and buttons. How does one build more custom/complex UI controls with it?

You can incrementally add client side only UI elements as you need - and if you want to use something more complex there are escape hatches which let you use your frontend framework of choice which can then hook into the LiveView process across the socket.

Re: React to LiveView for Performance [audio]

#32
Is it possible to get on Phoenix nested controllers? Like in remix.run, where for each route segment we get one controller/view. It’s really generalised version of layouts.

When I was looking into Phoenix all routes, no matter how nested, had to resolve to single controller. That meant that controller for path `/user/settings/privacy` was also responsible for getting data to display users sidebar.

Re: React to LiveView for Performance [audio]

#33
post #30

Earlier quoted context omitted.

Yeah, that sounds so strange. I've had thousands if not tens of thousands of components, reacting to objects that contain millions of data points that felt native.

With 6x CPU slowdown (although not enough anymore) or a "normal" computer? React isn't exactly fast, in fact it's pretty slow. Developers just think it's fast because they have $4000 Mac Book Pro's.

Yeah, apps/sites should be tested with consumer-grade hardware and software - the browsers they have (most likely edge/chrome), with some other applications and tabs open in the background.

Re: React to LiveView for Performance [audio]

#34

I’ve been wanting to use LiveView so bad, it’s just incredibly hard to justify to a team when React is working just fine :(

Sometimes you can come in the side door. I built a testbed reservation app for the GUI team I work with using Phoenix LiveView. The Product manager was surprised out fast I hammered it out. So far everyone is using it without a hitch. It's not product code, but it's still in active use with no problems.

Re: React to LiveView for Performance [audio]

#35

Earlier quoted context omitted.

With React / TypeScript, even the setup of the test suite as I mentioned is painful, which one do you use? playwright? that one is going to be slow and cumbersome, LiveView's built in test suite does the same thing and is much more lightweight and fast. If not playwright which do you use? Jest? Vitest? this is the problem with JS community, too many choice on things that in the end don't matter to the end user. Also…

But many already have API endpoints because you have to serve native apps too. My question was, does LiveView also help you in a Backend-for-Frontend case?

He did kinda answer your question with: "I ended up removing a lot of controllers from my codebase that was there just to service the react front-end. Having those controllers do not service as the "API" of the app. Specs for front-end apis and core APIs are usually quite different based on my experience"

Re: React to LiveView for Performance [audio]

#36

Earlier quoted context omitted.

But many already have API endpoints because you have to serve native apps too. My question was, does LiveView also help you in a Backend-for-Frontend case?

This is why I'm eagerly waiting for LiveView Native. That will remove the need for front-end APIs entirely.

Oh that's interesting. It won't need to remove the need for APIs (there are scripts and other clients, like embedded, that LiveView will likely not support) but cool.

Re: React to LiveView for Performance [audio]

#37
post #30

Earlier quoted context omitted.

Yeah, that sounds so strange. I've had thousands if not tens of thousands of components, reacting to objects that contain millions of data points that felt native.

With 6x CPU slowdown (although not enough anymore) or a "normal" computer? React isn't exactly fast, in fact it's pretty slow. Developers just think it's fast because they have $4000 Mac Book Pro's.

Commercial grade apps where I do throttle CPU.

If you are only re-rendering what is required, it's just a webpage at rest.

Re: React to LiveView for Performance [audio]

#38

Is it possible to get on Phoenix nested controllers? Like in remix.run, where for each route segment we get one controller/view. It’s really generalised version of layouts. When I was looking into Phoenix all routes, no matter how nested, had to resolve to single controller. That meant that controller for path `/user/settings/privacy` was also responsible for getting data to display users sidebar.

[deleted]

Re: React to LiveView for Performance [audio]

#39
post #30

Earlier quoted context omitted.

With 6x CPU slowdown (although not enough anymore) or a "normal" computer? React isn't exactly fast, in fact it's pretty slow. Developers just think it's fast because they have $4000 Mac Book Pro's.

Commercial grade apps where I do throttle CPU. If you are only re-rendering what is required, it's just a webpage at rest.

> If you are only re-rendering what is required, it's just a webpage at rest.

As someone who has used React since 2015, and has worked on tons of React apps, with a wide range of team members and skill level, this is easier said than done. First of all, some developers just don't "get" React. The framework has a lot of foot guns, especially around performance. The most productive I've ever seen a team is with Mobx, which does fine-grain updates out of the box if you model your state correctly.

Getting great performance in vanilla React requires constantly thinking about where state lives, lifting, lowering state, composition, and memoization. It's not exactly fun, requires a ton of diligence, and most developers can't architect a simple table that has interactivity that just re-renders a single row instead of the entire table.

It's not the fault of the developers, it's the framework that has poor performance, has a team that doubles down on awful architecture, and doesn't have the empathy of what it's actually like working in React day to day with just normal developers.

Compare this with Solid or Svelte, which have fine-grain interactivity, and you don't have to refactor your components changing where state lives constantly. You can actually describe your UI with components based on where they should live, not how they should update. Contrast that with React, which requires you to describe your UI and state by how it's updated, not where it makes sense.

In a world with advancing AI and great new frontend frameworks, why are we specifying memoization dependencies manually? It's a joke. The model of a component executing top-down every change has to go. The react-forget compiler has been in the works for years at this point. I've moved on, so should you.

I could rant on this for hours, but that's the gist.

Re: React to LiveView for Performance [audio]

#40
post #15

Whenever I see examples of LiveView being used it all works seamlessly but the UI always looks very simple, like basic forms, links and buttons. How does one build more custom/complex UI controls with it?

I guess it depends what you mean by "complex ui controls". You can add "hooks" that attach to any normal element. Those hooks have access to push/pull data/events down the socket, so you can basically set up listeners on any element to trigger what would be your normal REST calls. In that respect you can hook your into integrating with a liveview process, but obviously it wont receive any DOM difffing etc. If your en…

Thanks for the detailed response. I took a look at a post where react was still used and driven by server-side state using liveview hooks which looked quite interesting.
Post reply on HN