6 ms·
Turbo frames and streams are a wonderful pattern that I wished was used more than it is. We see people resort to whole React frontends for their web applicatio
by xutopia 3y ago
Turbo frames and streams are a wonderful pattern that I wished was used more than it is. We see people resort to whole React frontends for their web applications just to add simple features that could be done nearly for free using frame and streams.
- dmix 3y agoYeah we did Vue pretty heavily and decided it wasn’t the right solution, except for a subset of things that require advanced UI complexity HTML+simple JS can’t offer (aka “islands of functionality”), since half our team is backend devs who just want to make regular simple Rails views. We’re planning a big shift to Turbo for all new feature development. So much complexity in JS is scary and doesn’t scale well when most of the serious app logic is in Rails. Even for me who was one of the first adopters of Backbone.js looong ago and I’ve been doing JS heavy frontends most of my career. If we had a more consistent SSR type solution to mix with Rails like Fresh or Remix or whatever I might be less tempted to switch but SSR is very premature unless you’re using a full JS framework which I have little interest in using, even though I write Typescript for a living.
- 0xblinq 3y agoBackend devs doing "just simple rails views" only works when those views are really simple, and mostly for internal tools. Otherwise it becomes a total nightmare to maintain. I agree the "popular" JavaScript solutions are a complexity, over engineering and maintenance nightmare (I'm talking about Next.js mostly here). But if you use somethink like Inertia, which TL;DR basically just makes React (or Vue) a templating library for your backend framework, it becomes super simple and easy to maintain. I find Inertia great because it's the perfect bridge that can make both backend and frontend devs happy, as it gives you the best of both worlds. Hotwire is great, but you do need to invest into its way of doing things, and believe me... backend devs who hate on JS doing frontends leads to disaster in the same way JS devs hating on PHP/Ruby/Etc doing backend also leads to disaster. Last year we replaced Hotwire in a medium size Rails app with Inertia because even if it was quite fast to build new features with, it became a total nightmare to maintain. Simple things such as a modal were split in 4 or 5 different files... some logic was in controllers, other in templates, then the stimulus controller for this and that, and the frames, and... nobody knew what to change. The problem with Hotwire is that you need to be super "creative" with your solutions and take decisions like should I use a stimulus controller, a frame, a stream? or what? at every single step, and a single functionality ends up split in multiple different places. While with React or Vue it would be just a single component with an isOpen=true/false and done. I insist... if you look at the "modern frontend" situation thinking on Next.js, Redux, css-in-js, etc... yes... it's a f*ng over engineering marketing hype bullshit hell. But React/Vue on their own do provide some real benefits and real solutions to actual problems. I think inertia brings to backend frameworks all the benefits of these tools, with minimal (and worth it, in my opinion) trade offs. If you end up using Hotwire, just be careful and be warned... it's very likely to become a mess sooner, especially if used by JS haters.
- x0x0 3y agofwiw, I disagree with your take on Hotwire: that's really all of Rails. Rails is built for expert users and you simply must be disciplined about how you build it or you will regret it; I don't think that's unique to Hotwire at all. I'm commenting to thank you for sharing Inertia though. Very interesting approach; I'm going to do some reading of the code. For everyone reading this, if you're curious, start here: https://inertiajs.com/how-it-works https://inertiajs.com/how-it-works
- 0xblinq 3y agoI think you're actually agreeing with me :-). Just extending my take to all of Rails, which I think it makes sense too. Yeah, Inertia is great. We're supper happy with it. It simplified a lot of things and makes us feel we're building something robust and maintainable.
- x0x0 3y agoApologies, my only disagreement was that it was Hotwire that requires care when I really think it's the entirety of Rails. Thanks again for the suggestion on intertia.js !