Re:Virtual DOM is pure overhead (2018)
by imtringued on Sunday May 19, 2019 @07:13AM
(#19952710)
Keeping the view state in the server is what Java Server Faces did and trust me you don't want to repeat that same mistake.
Here's an interesting response from Elixir's creator (and contributor to LiveView) specifically about JSF:
https://elixirforum.com/t/phoenix-liveview-is-now-live/20889...
I don't know JSF so I can't really argue this point, but I'd really love to hear what you think about the argument Jose put forward and where you might disagree!
I kept a real nasty implementation of this alive for the last two years while building a REST api and React frontend to replace it.
I learned a good lesson, though: no logic in template files! Ever!
I mean, it's better than having to maintain both server- and client-side logic and state (and having to sync all that), and definitely better than the days where we also had to manage DOM diffing manually.
But I still get headaches from the NPM/node ecosystem, the build steps, having to decide whether logic goes on the client, server, or both, and to some extent javascript itself. And you can never fully let go of the server-side of things.
I'm very intrigued by the alternative idea of moving (almost) everything to the backend, and maintaining the dynamic bits by sending all events to the server and sending back diffs based on that which update the page. Phoenix'/Elixir's LiveView made some great progress in this area, and from what I hear other ecosystems are experimenting with the same thing.
It's not a panacea: if you need offline functionality you're gonna have to deal with js and everything that comes with it. But in many projects that's not a deal-breaker, and in practice the approach actually leads to smaller payloads sent between client and server, and significantly simpler codebases.