DAVID HILL Happy Wednesday and welcome to the show. I'm your host, David Hill, and joining me today is my first repeat guest, Jeremy Smith. Welcome to the show again, Jeremy. Hey, thanks, David. It's glad to be here. So our previous episode, we were talking about Blue Ridge Ruby. Yeah. And the kind of aftermath of Blue Ridge and how it went and everything. And this time we're talking about a different conference because Rails World is coming up and you're giving a talk at Rails World. JEREMY SMITH Yeah, I am. It's kind of funny. just put my talk submission in kind of on a whim thinking this is not going to get picked and then it did and it was like a few weeks or maybe like a month after blue ridge and i was like oh shoot okay guess i'm doing this and it's a talk i've really wanted to give but i was also thinking maybe i'd have a quieter rest of the year but turns out no it's not been quieter oh no this talk has for some reason snowballed and like taken over my life. You know, I time track everything. I've talked about this before probably. And like with Blue Ridge this year, I think it was somewhere around, I can't remember, something like 300 hours for the conference. I'm at 128 hours on this. Talk. It normally takes me like around 50 hours to do a talk. And I gave myself more time to work on this because I had a lot to dig into and wanted a good research phase to like kind of ground everything that I was doing. But it's just gotten away from me. Wow. I have so much more material than can fit into 30 minutes. And I can see the end, but I'm like deep into slides now. I still have more to do. Oh, geez. I've got three weeks left. It's going to be fine. Everything's going to be okay. But this is just like kind of took over the summer. DAVID HILL geez. JEREMY SMITH is just like kind of took over the summer. DAVID HILL Okay. So the topic for your talk is stimulus and turbo hotwire, right? Yeah. I'm curious. What about it has gotten away from you? JEREMY SMITH Yeah. Was there a metaphorical wrong turn you took where like you'd went down a rabbit hole you didn't really see was there or like what happened? DAVID HILL turn you took where like you'd went down a rabbit hole you didn't really see was there or like what happened? JEREMY SMITH Okay. I guess let me back up and just say like, so the talk is called practical hot wire. It's turbo and stimulus on the ground. That's the name of the talk. And I've had this idea for a talk for a couple of years and primarily because in a lot of my consulting work, freelancing and in my own projects, my own side projects and stuff, hot wire is just what I've been doing. So I've spent a lot of time doing stimulus and turbo in particular. I've seen a lot of things go sideways with both and had to clean up a good number of messes that you can make with them. And a lot of people have talked about in the past, there being sort of a thin documentation around both and confusion about how to use them. And some of that has been valid in the past. I think it's gotten better. It's definitely gotten better. And we're even recording today. Earlier this week, they announced the official Hotwire guide is going to be landing in Rails. So I took a peek at that a little bit. That's still in review. So that's awesome. But it's been hard for people to figure out where to go. And there have been a lot of unofficial guides like blog posts and a couple good books and some good particular websites. But it's these different techniques and tools all fall under this umbrella, but it's hard to make sense of all of them, how they all fit together. DAVID HILL going to JEREMY SMITH So I think cohesiveness has been part of the issue. But I've also, in working on this, I've developed my own set of patterns, my own instincts around how to use these tools well. DAVID HILL So you're saying you're an opinionated developer when it comes to these tools? JEREMY SMITH comes to these tools? Yeah, I'm opinionated. And my opinions... don't match a lot of other people when it comes to hot wire and don't always match the official sort of blessed way to do hot wire. So a lot of this has been for me sort of trying to negotiate that and figure out, okay, what are my instincts right about? Like, how do I get really clear on this for myself? Because what I do, you know, with my own projects or even to some extent with my client work, I can sort of negotiate just with my client or just on my own stuff about how we approach hot wire. But if I'm going to give a talk at Rails World, how do I present in a way that I feel like is fair for the sort of an official platform, like conference, if that makes sense. Yeah. And have the data, all the data to back it up and have all the research grounded. So I started with a pretty extensive research phase in maybe in June, July, early July, reading books. going back through all of the Rails World talks that had to do with Hotwire, making sure that what I had fit all of that, going back to the official Hotwire guides, not the Rails guides, but the Hotwire guides, and kind of with pen in hand, doing a bunch of note -taking on those. And that was really helpful. And then my plan for the talk was to do a tour through... Well, DAVID HILL Yeah. JEREMY SMITH let me back up. Hotwire is stimulus, turbo, and... So it's these three parts under this umbrella. Hotwire is not Rails. Rails is not Hotwire. They can go together. They don't always go together. There are people that are using Hotwire that don't use Rails, and plenty of Rails shops don't use Hotwire. The official guides are somewhat agnostic about the backend framework. They might reference it in some places, but they're not particular to Rails. That's been one of the things I've noticed that has been a critique. of them and partly why having the official rails guide for hotwire is really helpful we have this umbrella and the umbrella is more of a philosophical term it's html over the wire hot wire but not necessarily a description of what the tool set does and then the tools underneath you've got stimulus turbo and native stimulus has been around for a good while turbo has three parts of its own drive frames and streams DAVID HILL official guides are JEREMY SMITH have this umbrella and the umbrella is more of a philosophical term it's html over the wire hot wire but not necessarily a description of what the tool set does and then the tools underneath you've got stimulus turbo and native stimulus has been around for a good while turbo has three parts of its own drive frames and streams Drive used to be called TurboLynx. So TurboLynx has also been around a while. Frames and Streams are newer, but Streams also had an earlier sort of spiritual precursor, which was, I can never remember this, server -rendered JavaScript. Have you ever touched in JS .ERB file in the Rails app? Yep. So this is like, Streams is like the spiritual successor to that. Frames is newer. Frames is a newer thing. Then you have the native piece. And native got renamed because it used to be Strata. DAVID HILL the Rails app? Yep. DAVID HILL to be Strata. Yeah, exactly. JEREMY SMITH to be Strata. Yeah, exactly. Yeah. So you have all these things that keep moving around. They're not all the same age. They didn't all come out at the same time. Some people have been using parts of this on their own, but they've sort of been pulled together into this, I would say, loose framework. They do work together. They're intended to work together. But it's also kind of like having a bag of tools where. It's not maybe obvious what they all do and how to use them all if you've not been working with them before. It's more like the bag of tools that your father has in the closet that they were all purchased at different eras from different stores. DAVID HILL It's more like the bag of tools that your father has in the closet that they were all purchased at different eras from different stores. And they go together somehow, but you don't know how and why they go together. Right. JEREMY SMITH they were all purchased at different eras JEREMY SMITH Yeah. They're not all pulled out and used in the same ways. They're not all used to the same degree. There's one tool in there that's just for a one kind of thing, and that's it. It's that kind of situation. But you're looking at the tools bag and you're thinking, oh, great. I got all these things. I can just use them all. And I think that's partly what people, even when they read the guides, they're still stuck on, okay, now what? Because there's overlap in a good bit of it. Oh, absolutely. Yeah. So a lot of the opinions I formed have been around when to use what and what to either ignore or use very rarely. And what I'm trying to do in this talk is put aside some of my own peculiarities around what I might do and try to speak to a more standardized approach that would fit an official platform, but also speak to what I believe are some of the difficulties or downsides of some of the tools. So the way I framed the talk is I'm ignoring native altogether. I've got stimulus and the three parts of turbo. So drive frames and streams. And so four sections. And I'm walking through three pitfalls of each of those. So it's basically a tour of most of what people use for hardware when they're building on the web. DAVID HILL So the DAVID HILL So drive JEREMY SMITH And then a tour through very common pitfalls I see in lots of projects for these. Or very common ones that people will run into. And then what to do about it. That was kind of already forming how I would do that, but going down and picking each one of those and then doing a lot of development to build out the actual example cases. So that meant building up a whole new Rails application with a bunch of different pitfalls and then their refactored versions, how I think you work around the pitfall or a thing that you can fall into. And thankfully, One thing that's probably everyone will, it's probably easy to guess, but like AI is like certainly not just changed development, but also really changed conference talk writing for me because I was doing all this research with Claude, like reading a lot, but also giving all my notes. And then developing all the examples of the things to walk through of things I've seen, like, hey, look at this repo where I run into this issue and how I solved it. Look at all the patterns for what I do with Hotwire. Then go look at the docs and tell me what you think is different between how I would do things and how the docs say to do things. So all kinds of running down lots of different rabbit trails, but things I never could have done before. It still took me too long probably, but. I was able to do quite a bit of extensive research that way and ended up with these 12 working examples for these different pitfalls. And so now I have like all the code for that and I didn't write it all, DAVID HILL lots of different rabbit trails, but things JEREMY SMITH now I have like all the code for that and I didn't write it all, but I was a micromanaging taskmaster, like technical lead over top of all of that. Like, here's the exact thing I want you to do and don't do it like that. No, it needs to look like this. Exactly. Right. And then that really sped up a lot of that process, but it was still very involved coming up with that many. Probably overly ambitious for a 30 -minute talk. I'm going to be moving rapidly through it. But what I'm trying to do is give a sense of the scope of Hotwire, the shape of the problems that you run into, and hopefully from there that gives people enough of a taste that they can then, I'm hoping to publish the rest of it so that people can go and use it as a reference tool after that. So that's what it looks like. And I'm talking in abstract, so maybe it's better to give you an example. So one of the common things that I'm going to give away my very first one, I'm starting with stimulus. In stimulus, you are creating this JavaScript controller, right? Stimulus is where you write most of your JavaScript with Hotwire. You're not writing a lot of JavaScript, but when you're writing it, you're probably writing it in stimulus controllers. And it's how you wire up your... JavaScript behavior to the HTML that you already have. And so you've got a controller, so it's a special kind of class and it has the ability to set targets. Those are these different HTML elements on the page that exists that you tie it to, and then it can listen on actions and pull in values that are data attributes and then make behavior changes based on that. And one of the things that stimulus gives you out of the box is this way of doing event listening on all these actions. But what I see a lot of people doing, or even agent code, agentic code or whatever, is creating all of the event listeners in the connect method. Oh. Yeah, which maybe is fine in some ways, but then they often forget to tear down in the disconnect, which can lead to various kinds of problems. When you're leaving a page, With Hotwire, the idea is you're never tearing down the full page. Turbo Drive is doing fetch requests for you and just swapping out the body for you and merging in the head. So it's never doing a full page cycle onto new page navigation. And so to handle that properly with stimulus, you need to make sure the lifecycle of your events is cleaned up. Otherwise, you've got listeners that still sit out there. Forever. So a lot of times people end up writing a lot of these event listeners into their connect method. Don't put them in a disconnect. And then don't use what stimulus gives you out of the box by setting the actions in the HTML. Right. And that's probably also why agents do it is because they're thinking, oh, you're going to do it in JavaScript. But the whole idea with Hotwire is you're writing more HTML than you're writing JavaScript. Yeah. DAVID HILL Yeah. JEREMY SMITH It's trying to make you write less JavaScript. That means you're writing more HTML. And that's just not as common. That's a really simple one. I start with a really, really simple one, but it gets a lot more complex. We sort of end with the final two examples are about TurboStreams and particularly about TurboStreams is actually protocol or a format for passing HTML into an existing page. It can be delivered to the page via a typical HTTP response. or from something like WebSockets or server -sent events. So we talk about TurboStreams, but when I was first starting doing this, I kept thinking Streams meant WebSockets. I always thought it meant WebSockets, and it doesn't. People are less confused about that now. But it's still confusing. The name Streams makes you think streaming. It's streaming. It's asynchronous. No, it's not. Like, Streams can be, but a lot of times you're using them just in your typical HTTP. requests response cycle right so the final two examples at the end of the talk are about the streaming portion if you're using web sockets and there are some particular things that are especially difficult with doing that so i'm hoping those will be a good place to land but i'm kind of walking through each all those things together and then like last month it hit me that talking through These different pitfalls, like should I talk about them as being sharp knives? You know, we have sharp knives and rails. In a sense, that's kind of what these are. Some of it, though, is about things you don't want to do. So it's more like pitfalls, like you'd want to just always avoid this. Where I ended up landing is, I don't know if you've ever seen the YouTube series Hot Ones. DAVID HILL I have seen that, yeah. JEREMY SMITH that, yeah. Do you want to see my slides? DAVID HILL Yeah, our listeners won't be able to see them, but I'll take a look. We'll just describe. JEREMY SMITH take a look. We'll just describe. So this is practical hot wire, which is style just like the hot ones. That's great. DAVID HILL hot ones. That's great. Oh, I love that. JEREMY SMITH And then here's me in front of all my hot sauce. Oh my gosh. So this is part of why it's taken me almost 130 hours. Oh, DAVID HILL this is so great. I'm so looking forward to this now. JEREMY SMITH looking forward to this now. So here's like the 12 hot sauces that you're going to get burnt by in this tour of hot wire. And then so each grouping like stimulus and each of the three parts of turbo, they're like in a flight of sauces, of hot sauces. And the lightest flight is like a jalapeno hot sauce. So these three green hot sauces here all have names. So the first one is, oh, I guess the first one I just mentioned was called paying for free listeners. And then the next one is tightly coupled controllers. And the last one is so much for server side using AI, of course, designed all these slick. hot sauces to put in a flight and that's the first flight and then i've got like the scoville units or levels for each one so i think it's gonna be fun one of the things that i realized like when it comes to talks it's really nice to have a theme it took me a little while to realize that with talks like it's really nice to have a theme because it gives you not just a visual style but something to keep connecting back and add sort of layered JEREMY SMITH think it's gonna be fun one of the things that i realized like when it comes to talks it's really nice to have a theme it took me a little while to realize that with talks like it's really nice to have a theme because it gives you not just a visual style but something to keep connecting back and add sort of layered DAVID HILL add sort JEREMY SMITH kind of depth to the talk it's just kind of a narrative that you're working through yeah yeah exactly it provides a structure sometimes constraints for you that help especially if you're like well how do i make this interesting or how do i frame this once you've got some like angle some hook it's really nice to be able to just work with that so DAVID HILL just kind of a narrative that you're working through yeah yeah JEREMY SMITH just kind of a narrative that you're working through yeah yeah exactly it provides a structure sometimes constraints for you that help especially if you're like well how do i make this interesting or how do i frame this once you've got some like angle some hook it's really nice to be able to just work with that so I'd been kind of struggling with that for a while. When I was like finally hit on hot ones, I was like, okay, I've got a bunch of things that can work here. It just got pretty fun, a little bit out of hand, DAVID HILL of hand, but I'm pretty excited about that. So I'm going to ask, would you mind if I took a screenshot of the very first slide? Yeah, absolutely. I feel like I need to have this in the show notes to display. Like totally, this is what we get to look forward to in a couple of weeks. Yeah. JEREMY SMITH That's phenomenal. Thanks. DAVID HILL I was already planning on being in the audience for this one, but you've already completely sold me here. JEREMY SMITH the audience for DAVID HILL already completely sold me here. This is so good. I am so on board for this. JEREMY SMITH Sweet. Thanks. That took a lot of time. I ended up using this pretty great tool. I don't know. I get annoyed talking about AI stuff, so you can stop me if it's annoying, but Flora is this AI product that's pretty amazing. I'm just kind of blown away at what you can do with... visuals. So I was able to take screenshots from YouTube of hot ones and then just like describe the hot sauce that I wanted. Like, here's the name of the section. Here's what it's about. Can you generate me hot sauces with the Scoville unit? I'm showing you here, like on the left, all the originals, like from the actual hot ones show. Right. And then here are all the examples that I generated on the other side. And I spent hours and hours doing this, like hours and hours generating lots of different variations. And sometimes it would get the Scoville levels wrong. And sometimes it would come up with imagery that I didn't really want, but iterating on this over and over again, I came up with ones I was fairly happy with. DAVID HILL I was fairly happy JEREMY SMITH with. And then once I had all the individual hot sauces, then I could combine all of those into my flights. So like say, take these three images and then put them all together on one. background and that actually worked pretty good and then i was able to put all those four flights of three into one shot with me and i had some kind of cursed imagery the editor here is kind of crazy with wow if you haven't checked it out but i was able to take pictures of me pictures of sean the host of the hot one show and the hot sauces that i generated and come up with like picture of me as if I was like the host of the show or whatever so kind of wild but all this tooling has definitely changed the way I would do in a talk now you know wow what's possible but having some kind of framing definitely makes it more interesting I think as an audience participant the talks where someone has some interesting framing it sticks with you longer you're like oh that's the talk about such and such It doesn't even have to do with the technical topic, but for whatever reason you remember the visuals or the storytelling or something like that, DAVID HILL like oh that's the talk about JEREMY SMITH or the storytelling or something like that, I think that really helps a lot. It makes a lot of decisions for you. Yeah, so that's kind of it. And I've had to put a bunch of research I've done, exploration, sort of to the side on the cutting room floor at this point. But I'm hoping to find some other use for it at some point. Initially, I think it will probably just be a website where I'll put all of the code samples for all the 12 things that I'm walking through in the talk so people can actually look at them. But then I've got others that I didn't have time to include. I thought originally, oh, I'll have a speed run section where I do like really fast ones. And I'm like, no, actually I don't have. Any time for that, I'm actually going to be speed running the entire thing. So that's not going to work. DAVID HILL that's not going to work. Okay. So this might be one of those talks that you have to rewatch a couple of times to catch everything. JEREMY SMITH I hope it's not hard like that, but it's possible. DAVID HILL Not that it's hard. Yeah. If you're having to speed run the whole talk, there might just be like details and nuance at some point that you're just like, I can't walk you through all of this, but feel free to pause it and look at it and you can see like how the problem evolves. But yeah. I would definitely have a better talk if I just picked one part, if I just was doing stimulus or something like that. JEREMY SMITH If you're JEREMY SMITH talk if I just picked one part, if I just was doing stimulus or something like that. It's not enough time to really let the details land about like some of the lessons. The first one I just told you is maybe obvious, but can use a couple examples for people to get it. DAVID HILL first one I JEREMY SMITH obvious, but can use a couple examples for people to get it. That's a really simple one. There are other ones that are more like you need to see it a few different ways. It can help to have some diagrams. to hear it stated in a few different ways and see a few different code examples for it. And I just don't have time for that, unfortunately. So I've got to kind of work through it pretty fast. But I recorded video screencast demos. That's the other thing that took so much time. It was after generating all the parts of the app for how they work, I sat down and recorded. demos of each one so you can see like this particular feature in action as i'm describing it and then we'll look at the code for it and see what went wrong with it and then we'll see the revised version and like how it's fixed or whatever so wow that also took a ton of time and i really don't like keynote but i'm getting better at it so i've heard that sentiment express before yeah yeah one of the things that is like Tempting to everyone that's a developer is to build their own presentation software at the beginning of the project. I have to resist that temptation every time. And I know plenty of people that either have the same temptation or sometimes fall for it. So it's super painful, especially with things like syntax highlighting in Keynote for code samples. It's super annoying. Thankfully, Vladimir Dementia, I found a random Dev2 article. that he wrote last year with like some apple scripts and using a like a cli tool for syntax highlighting and that's helped immensely so it's way better than the last time i had to do this but it's still a pain so i thought at this point in the time i would have a pretty polished talk that I would be sending off to some friends to get feedback on. I think it's decent, but I still know so many more things that I need to do before I could even ask, okay, I think it's done. Now I'm ready for other people. I still have like so many other things that I would like to hit, you know, like to feel really, really good about. So unfortunately that's just how it went on this one, but like it's giveable right now. I just want it to be as good as possible for rails world. So maybe another 20 hours. DAVID HILL just want it to JEREMY SMITH another 20 hours. Wow. Something like that. DAVID HILL So you're on track to hit like 150 hours on this? Half a conference. Half of organizing a conference. JEREMY SMITH of organizing a conference. It's insane. DAVID HILL Should not have happened. JEREMY SMITH not have happened. I don't understand. Yeah. DAVID HILL Wow. From what you showed me already, it looks like it's going to be really good. Thanks. I'm already excited for this talk and for all of the hot ones. Yeah, all the references. Jokes or puns or whatever. I'm assuming it's going to be littered throughout. JEREMY SMITH Jokes or puns or whatever. I'm assuming it's going to be littered throughout. Yeah, exactly. DAVID HILL Maybe this skews into the content of the talk a little too much to really be able to answer it well. But back towards the beginning of the conversation, you mentioned you've got opinions about how Hotwire should and shouldn't be used. JEREMY SMITH be able DAVID HILL towards the beginning of the conversation, you mentioned you've got opinions about how Hotwire should and shouldn't be used. Do you have any particular hot takes that you could share about? how you should or shouldn't use pieces of Hotwire? JEREMY SMITH I have one in particular that I feel like I'm not ready to share because it's so spicy. Oh, DAVID HILL Oh, JEREMY SMITH okay. Okay, so when I've tried this on with friends, the reaction has almost always been negative. I'll say what it is. I can't maybe defend it yet, although I have now a huge pile of notes. You're building the defense. I have built the defense. I just haven't published the article. Okay. DAVID HILL building the defense. JEREMY SMITH In my experience, in my view, people should rely primarily on turbo streams and not on frames. Interesting. I avoid frames in almost every situation except for one. I've landed on one use case for frames that is the only situation I would personally reach for it because there's nothing better than that. but I would use streams for almost everything else. It's not what I'm going to be saying in the talk. It's not the blessed perspective on, on, right. DAVID HILL right. JEREMY SMITH It is how I will approach my own projects and what I will advocate for my clients and for anyone I care about. DAVID HILL That is interesting. JEREMY SMITH Yeah. When I've tried to explain this before, it's not people definitely disagree. especially anyone that's worked with hot wire significantly, they hotly disagree with me. And this leads me to like one thing that I was trying to figure out, okay, you know, I'm trying to like figure out how to thread the needle with this talk so that I'm presenting in an official way that people feel confident, like I'm getting something good that the Rails ecosystem would sort of bless in some way, but also like give my own perspective on it. Sure. So where I've kind of landed with the talk is I'm walking you through what I believe are clear pitfalls, Some of those you might still decide, okay, there are trade -offs here and I'm still willing to do this other thing. That's one reason I moved away from the pitfall language is like some of them feel like a burn and you might say, well, no, that spice level is fine for me. Right. Okay, cool. But I think we can all agree that you don't want to be like on heartburn medication if you can help it. We should all like enjoy some spice in life, but you don't want to be, you know, constantly taking Tums or whatever. Oh my gosh, this is going to be such a great talk. DAVID HILL this is going to be such a great JEREMY SMITH talk. But I think one of the things that I've landed on over the summer is realizing that one of the things that makes a good framework is enough rigidness that anyone can come into a project using the framework and understand it, know how to use it, know what they're looking at and how things work, but enough flexibility to allow house styles to emerge. And I'm sort of dropping sort of one of the landing points of the talk here, but I think it's an important one because I think that having flavors or house styles is actually a sign of health in an ecosystem. And that kind of variation is really valuable and is a sign of a good framework. And this happens in Rails, you know, and in Hotwire, but I've seen it, especially with Rails, that different companies or different agencies or almost subgroups within Rails have had different flavors to Rails. For years, I read the ThoughtBot blog religiously, and that was sort of like their style of Rails heavily influenced me for many years. But I also read the Arkensee blog, and they do event sourcing and a totally different style of Rails. There's so many different patterns. It's more than patterns. I think it was almost like a larger approach to architecture that can be developed in a larger company context or sometimes within like a handful of maybe agencies or learning groups that have kind of come up together. And so I think Hotwire has the potential for that as well. It's newer. It's not 20 years old like Rails. Right. It's still pretty young and has room to evolve and grow and change. DAVID HILL Right. It's still pretty young and has room to evolve and grow and change. JEREMY SMITH Yeah, exactly. Hopefully this ends up being just a contribution to like one of the house styles for that or an attempt at explaining that. And then people can take what they want from it. Cause I've done that with rails, you know, I've picked and chose what I've liked out of various styles from the things I've learned and all of it together has been sort of a rich environment to pull from. And over time you kind of learn what. you want to adopt and what works well in what situations because sometimes it is situation dependent and there are actually quite a few things here in hotwire that are situation dependent yeah they're huge situation dependencies the one time i got to seriously work with hotwire is one of those moments where there's so many ways like it's not only situational dependencies it's also just like DAVID HILL there are actually quite a DAVID HILL they're huge situation dependencies the one time i got to seriously work with hotwire is one of those moments where there's so many ways like it's not only situational dependencies it's also just like i could literally do this in any one of three ways yeah i could use streams i could use frames i could do it with stimulus now i need to figure out which approach is actually going to be the better direction to go yeah there is some way of like distilling down i think a little bit here one thing to say is like that drive is kind of like JEREMY SMITH is some way of like distilling down i think a little bit here one thing to say is like that drive is kind of like turn it on and just, you'll almost forget about it. You almost don't do anything. Almost just, yeah. There are a couple of things that could trip you up and I will be talking about those. It's mostly about just understanding the mental model of what it's doing. Right. Otherwise you're pretty much just leaving it alone. DAVID HILL about it. You almost don't do anything. Almost just, yeah. JEREMY SMITH Stimulus comes in whenever you need anything like you want an emoji picker on the client side. Well, you're probably going to pull out, you know, a vanilla JS emoji picker. And you're going to wire it up to your existing HTML with a stimulus controller. Half of what I write in stimulus controllers is wiring some third -party JavaScript library up to my Rails app. That's half of it. The other half is sometimes very specific component behavior or sometimes very basic show -high toggles or reveals or things like that. So things like that. In some ways, stimulus could almost just give you the library out of the box. There's so many things that I copy from previous, like stimulus is one area where you're just copying the same controllers from one project to the next, to the next, to the next. Oh, I know I've done this before. I'll make minor tweaks to it and like bring it in again. DAVID HILL Yep. That's just how it works. So it's mostly you're creating like client side behavior with stimulus controllers and either wrapping more complex third party plugins, JEREMY SMITH creating like client side behavior with stimulus controllers and either wrapping more complex third party plugins, components, or creating behavior that you don't get just with basic HTML. So most of the decisions that you're making in hot wire come down to streams versus frames. That's really where the crux of when you're making choices about what your views do, what your controllers do and what your background jobs are doing. If you're using streams, it's frames versus streams. That's most of it. Right. And I've come to some views about how that works well. but there are trade -offs and sometimes you make different choices depending on what bets you're making one of those bets is how many clients do i bet will be connected to this page and that will be big part of the choice that you make about that okay well whenever you get around to publishing this work that you've done about this hot take yeah i would really like to see this so please keep me in the loop whenever you DAVID HILL those bets DAVID HILL well whenever you get around to publishing this work that you've done about this hot take yeah i would really like to see this so please keep me in the loop whenever you are ready to release that because because it is kind of a contrarian opinion a little bit whereas like oh yeah you know frames is kind of positioned as this is where you start with turbo and because i think conceptually it's easier to explain it's easier to kind of understand oh i know what to do here and i know how to build a page with frames yeah and getting into streams it's a whole other kind of bag of cats JEREMY SMITH that you've JEREMY SMITH because because it DAVID HILL is kind of a contrarian opinion a little bit whereas like oh yeah you know frames is kind of positioned as this is where you start with turbo and JEREMY SMITH little bit whereas like oh yeah you DAVID HILL because i think conceptually it's easier to explain it's easier to kind of understand oh i know what to do here and i know how to build a page with frames yeah JEREMY SMITH i know how DAVID HILL getting into streams it's a whole other kind of bag of cats JEREMY SMITH Maybe partly why I haven't felt that because I've heard this before. Partly why I have not felt that myself is that before this, I was writing JS ERB files. So everything that you were doing back then with SJR or SRJ, I can never remember the acronym. DAVID HILL I think it was SJS. JEREMY SMITH I know it's in my talk, but I always forget the acronym. It's from like 2013. I don't know. DHH came up with it. UJS, unobtrusive JavaScript. I'm not even thinking about UJS. I'm thinking specifically about JS .ERB files where you make a request, the controller handles a response and renders a JS .ERB file, which returns JavaScript to the browser and performs some action. DAVID HILL even thinking JEREMY SMITH And that was conceptually very similar to what TurboStreams are doing, other than if you ignore the async part of it. Just think about... when streams are used in an HTTP request response cycle, DAVID HILL but it said it's safer because you have a limited set of actions. You can append, JEREMY SMITH it said it's safer because you have a limited set of actions. You can append, you can replace, you can prep end, you can remove or whatever it's called. You've got an HTML payload that's embedded in a template tag. So that just streams through this small bit of markup. And then on the page, turbo sitting there waiting for that. When it finds that new turbo stream event lands on the page, then it, runs the command to make that incision or whatever it's doing. DAVID HILL Whatever the change was that it was supposed to be. JEREMY SMITH Whatever the change was that it was supposed to be. Yeah. So to me, that was always how I was doing it before. People talk about it being surgical updates to a page and it is, but one of the big difficulties with frames is it only affects one region. So as soon as you need a request to affect multiple regions, you've hit the wall. you've hit the dead end of turbo frames and then people reach for things that lead to a lot of indirection at that point like embedding streams and frames and thinking that that's not leading to more indirection or more difficulty in understanding it or adding a stimulus listener to the frame and when it comes back making a request making additional requests yes also more indirection right and much of my opinions about DAVID HILL additional requests yes also more indirection JEREMY SMITH right and much of my opinions about Hotwire and Rails have come from a lot of the problems I've had to solve in existing code bases. The patterns that have emerged from my work have mostly been through working legacy code bases. Yeah. Working with not Greenfield, where I'm just coming up with stuff on my own, but coming in to something that exists that's having problems or needs to be fixed, something that's not working. It's falling under the weight of whatever the patterns are. It's not sufficient for at this point. Or trying to understand something that I didn't write and having to navigate that. And that's partly what the indirection I'm mentioning is a problem for. It's maybe not a problem when you wrote it the first time, but when you come back two years later or somebody else tries to deal with that, it's much harder to find. So that's partly where that comes from. But frames is easy conceptually, but in my opinion, limited in a way the streams is not. And streams gives you both sync and async. DAVID HILL Well, yeah. So like I said, whenever you're ready to release more about what you're thinking about that stuff, I would love to see that. I'm really looking forward to this talk and to seeing you in Austin in a couple of weeks. JEREMY SMITH Thanks, David. Yeah, I appreciate it. I've been nervous this whole way. Like, I think maybe a couple of weeks ago, I was thinking, oh, I hate this talk. What am I doing? I think I'm past that. Once I got the hot sauces down, I was like, okay. Maybe I can like this talk. Oh, good. DAVID HILL can like this talk. Oh, good. We're getting there. One point of feedback. Yeah. Got one person who's looked at this and said, oh, I want to see the rest of this talk. Thanks, man. Yeah. JEREMY SMITH Thanks, man. Yeah. Thanks. I appreciate that. Yeah. DAVID HILL Well, thank you so much for coming on the show and sharing a little bit of the joy of preparing a talk for Rails world. JEREMY SMITH Yeah, absolutely. Yeah. Thanks, David. DAVID HILL This has been the Ruby on Rails podcast. It was a pleasure talking with Jeremy today. Thank you to JudoScale for sponsoring this podcast, and thank you for listening.