3 ms·
Everytime LiveView or Phoenix pops up here in HN, people always mentions how much they enjoy the framework. It feels to me like it's something I am missing out
by Alifatisk 3y ago
Everytime LiveView or Phoenix pops up here in HN, people always mentions how much they enjoy the framework. It feels to me like it's something I am missing out on?
I am Ruby/Rails developer myself and StimulusReflex seem to be the equivalent but idk, is my feeling true?
- sph 3y agoNo it is not equivalent. My dream stack that I am using for my business is Phoenix, Live View and Stimulus.js with Tailwind. I have built projects on Laravel, Django, RoR, React and a long tail of in house frameworks, and nothing feels as good as this stack for web apps. Ruby on Rails is quite underrated, but the BEAM is a spaceship that fits neatly in the list of unknown unknowns for 99% of software engineers: they do not know what the BEAM can do for them. Its process and mailbox model feels futuristic in its expressiveness and simplicity. It's easier than you think to get used to Elixir's functional language model. For me it was super easy, while with stuff like Haskell or Prolog I felt like I had to rewrite my brain from scratch. To end my proselitism, I am adamant that the first Live View demo by McCord and Valim will have the same staying power if not popularity as DHH's first demo of Ruby on Rails which spawned the modern MVC framework architecture of the past 15 years. The Live View model is in my eyes the next generation of interactive web architecture, the true successor to MVC.
- pbowyer 3y ago> My dream stack that I am using for my business is Phoenix, Live View and Stimulus.js with Tailwind. I am curious, why both LiveView and Stimulus.js? Why and how are you combining the two together?
- sph 3y agoFor very small interactions, there is no need for a round trip and state held on the server. Imagine a disappearing burger menu, or a tooltip widget, or a "click here to copy to clipboard" link. For those sprinkles of interactivity, you need JS and Stimulus is ideal for that use case. I just have my Live View process render <input type="text" data-controller="copy-on-click" value="..." /> which is easy to understand and plays great with Live View's model. Don't forget that JS was born for this goal: small snippets of interactive behaviour; it was never meant to be the entire system.
- clessg 3y agoOh wow that's brilliant, I hadn't ever considered combining LiveView and Stimulus.js. If you don't mind me asking, what is the benefit over using `phx-hook`? Portability/interop with RoR, or? Either way, I'm shipping it to production immediately!
- sph 3y agophx-hook is a nice convenience that works only with Live View. It seems to me a better investment of my time to learn a solution that's just as lightweight, but I can use everywhere (i.e. in other projects, or in static non-Liveview pages)
- clessg 3y agoMakes a lot of sense, thank you! I'm not much into Rails these days, but that's one thing I really appreciate about RoR's "frontend" efforts - their work tends to be quite reusable across ecosystems, e.g. Stimulus, Turbo, and apparently even Hotwire itself [0]. Heck, that even seems to apply to a lot of their non-frontend stuff, such as MRSK [1]. [0] https://www.akshaykhot.com/using-hotwire-without-rails/ https://www.akshaykhot.com/using-hotwire-without-rails/ [1] https://mrsk.dev/ https://mrsk.dev/
- sph 3y agoYeah RoR with those libraries are also moving towards the "as little JS as possible" approach as well. Client-side logic makes sense in a vacuum, but then your crappy React app is in fact a distributed system, with all the complexity that entails. The radical idea of Liveview and similar efforts is that it's better just to return to basics and keep the logic on the server. It would be lunacy to try and build a distributed system with Javascript, yet that's the direction the SPA world is/was taking us.
- brainbag 3y agoI've seen alpinejs mentioned alongside LiveView, what benefits do you see to Stimulus over alpine?
- alostpuppy 3y agoDo you have a link to that demo?
- sph 3y agoThe Live View demo or the Rails one? :-) Rails, it was this one 17 years ago: https://www.youtube.com/watch?v=Gzj723LkRJY https://www.youtube.com/watch?v=Gzj723LkRJY Live View, I'm not sure which is the first demo. There's "Build a real-time Twitter clone in 15 minutes with LiveView and Phoenix 1.5" (https://www.youtube.com/watch?v=MZvmYaFkNJI https://www.youtube.com/watch?v=MZvmYaFkNJI)