Michael Kennedy: Building on the web is like working with the perfect clay.
Michael Kennedy: It's malleable and can become almost anything.
Michael Kennedy: Too often, frameworks try to hide the web's best parts away from us.
Michael Kennedy: Today, we're looking at PyView, a project that brings real-time power of Phoenix LiveView
Michael Kennedy: directly into your Python world while keeping the web elements front and center.
Michael Kennedy: I'm joined by Larry Ogrenek to dive into PyView.
Michael Kennedy: This is Talk Python To Me, episode 535, recorded January 9th, 2026.
Michael Kennedy: Welcome to Talk Python To Me, the number one Python podcast for developers and data scientists.
Michael Kennedy: This is your host, Michael Kennedy. I'm a PSF fellow who's been coding for over 25 years.
Michael Kennedy: Let's connect on social media.
Michael Kennedy: You'll find me and Talk Python on Mastodon, BlueSky, and X.
Michael Kennedy: The social links are all in your show notes.
Michael Kennedy: You can find over 10 years of past episodes at talkpython.fm.
Michael Kennedy: And if you want to be part of the show, you can join our recording live streams.
Michael Kennedy: That's right.
Michael Kennedy: We live stream the raw uncut version of each episode on YouTube.
Michael Kennedy: Just visit talkpython.fm/youtube to see the schedule of upcoming events.
Michael Kennedy: Be sure to subscribe there and press the bell so you'll get notified anytime we're recording.
Michael Kennedy: Hey, everyone.
Michael Kennedy: A quick announcement.
Michael Kennedy: I recently added a pair of features to talk Python to me to make it work way better with AI.
Michael Kennedy: For example, you can ask questions such as, what was the last episode?
Michael Kennedy: Or which episodes featured David Lord?
Michael Kennedy: The AI can use a couple of endpoints, a new MCP server implemented in Quart,
Michael Kennedy: and the emerging llms.txt standard to answer those questions with 100% accuracy and real-time data.
Michael Kennedy: If you use an AI that supports MCP, then take just a moment and install our MCP server.
Michael Kennedy: If not, you can always point your AI at talkpython.fm/llms.txt to get it started talking about the show.
Michael Kennedy: Weirdly, ChatGPT says it can't read that file on our website and it gets a 400 response code,
Michael Kennedy: even though asking it to do so results in a 200 okay from the open AI bot in our logs.
Michael Kennedy: Oh well, for chat, you'll just have to copy the contents into your prompt until they fix whatever weirdness this is.
Michael Kennedy: I did a write-up for this on the Talk Python blog called Announcing Talk Python AI Integrations at talkpython.fm/blog.
Michael Kennedy: The full link is in your later show notes.
Michael Kennedy: I hope you enjoy this new way to interact with our over 7.5 million words of content at Talk Python To Me.
Michael Kennedy: Thanks for listening. Now let's get on to the show.
Michael Kennedy: Larry, welcome to Talk Python To Me. Awesome to have you here.
Michael Kennedy: Yeah, thanks, Michael. It's great to be here.
Michael Kennedy: I saw your project, PyView, and you're like, oh, hey, maybe you could just give it a little shout-out.
Michael Kennedy: And I'm like, this is super neat, the way this thing works.
Michael Kennedy: And as most people know who listen, I'm a big fan of web development.
Michael Kennedy: The last episode that we just released, not actually the one,
Michael Kennedy: time shifting because of recording podcasts,
Michael Kennedy: was with all the creators of the popular Python web frameworks as a panel.
Michael Kennedy: And that was super popular.
Michael Kennedy: So here we are back with another web topic, PyView.
Michael Kennedy: And it's got a really, really unique twist.
Michael Kennedy: And I think people are going to dig it.
Larry Ogrodnek: It's quite interesting.
Larry Ogrodnek: Gosh, I've been doing technology for a long time now,
Larry Ogrodnek: and I think the web has always just been amazing, right?
Larry Ogrodnek: It's an amazing platform, and so I think that's why people
Larry Ogrodnek: kind of gravitate towards web frameworks
Larry Ogrodnek: and interesting web technologies and what can you do now
Larry Ogrodnek: and how can we make it easier?
Larry Ogrodnek: Yeah, it's funny.
Larry Ogrodnek: I did think PyView would resonate with you a little bit
Larry Ogrodnek: just because I know that, I don't know if this is true,
Larry Ogrodnek: but it seems like you do appreciate really not just like,
Larry Ogrodnek: you know, obviously Python, but web technologies
Larry Ogrodnek: and especially like embracing web technologies
Larry Ogrodnek: and maybe not necessarily kind of hiding them.
Michael Kennedy: Yeah, exactly. That is one of the things that really appealed to me because there are some Python frameworks that build webmaps, but their goal is to pretend that HTML and CSS is really bad. It's like, you don't want to write a simile. We're going to put that away from you. You don't need to see this HTML or the CSS or any of those things. Get it away. And I feel like something is lost there.
Michael Kennedy: Like building on the web is just, it's like the perfect clay, right?
Michael Kennedy: It's, it is so malleable and it can become almost anything that you want it to be.
Michael Kennedy: And a lot of those frameworks, I think they just miss that.
Michael Kennedy: And I don't feel like what you built does.
Michael Kennedy: So I'm going to be, I think we're having a good time talking about it.
Larry Ogrodnek: No, thanks.
Larry Ogrodnek: Yeah, I'm excited to get into it.
Larry Ogrodnek: But quick introduction, Larry, who are you?
Larry Ogrodnek: Thanks.
Larry Ogrodnek: Yeah.
Larry Ogrodnek: So my name is Larry Ogranik.
Larry Ogrodnek: I've been a software developer for, you know, I guess let's just say over 25 years now.
Larry Ogrodnek: I don't age myself too much. But through that time, obviously, I've done a bunch of different
Larry Ogrodnek: things and worked at startups. I worked at big companies. I've worked at freelancing for a few
Larry Ogrodnek: years even. And so my early career, it was more kind of on the C pro side, a lot of backend work,
Larry Ogrodnek: diving into Java and then Scala. And when I was doing freelancing, obviously the language of the
Larry Ogrodnek: tech kind of depended on the client wanted to do and what the project entailed. But that's kind of
Larry Ogrodnek: to get more serious about using Python.
Larry Ogrodnek: And nowadays, I work at a startup in the construction industry.
Larry Ogrodnek: And we think of ourselves--
Larry Ogrodnek: JOHN MUELLER: Oh, really?
Larry Ogrodnek: Yes.
Larry Ogrodnek: But we're really trying to invest heavily in technology
Larry Ogrodnek: and software.
Larry Ogrodnek: We're trying to be a technology-enabled home builder.
Larry Ogrodnek: And so we have a huge investment.
Larry Ogrodnek: And we have-- I mean, not necessarily a huge tech team,
Larry Ogrodnek: but spending any money and employment on tech
Larry Ogrodnek: is kind of a big deal in this industry.
Larry Ogrodnek: And I think it's an industry that hasn't really had technology get great adoption.
Larry Ogrodnek: Different people are doing different things, but overall, there's been a hard time to kind of get it in that process.
Larry Ogrodnek: But there's a lot of areas for improvement.
Larry Ogrodnek: And so, you know, we're trying to make that process better, faster, smoother.
Michael Kennedy: I think there's a lot of possibility for pick your underserved by tech specialization and build businesses around there.
Michael Kennedy: If you're a Python developer or any kind of developer.
Michael Kennedy: But if you really have the skill to build things like connecting APIs and automations and stuff,
Michael Kennedy: it's just such fertile ground.
Michael Kennedy: It's like, wow, there's nobody building stuff here that is like, good.
Michael Kennedy: Let's go.
Michael Kennedy: I could do this, right?
Larry Ogrodnek: 100%.
Larry Ogrodnek: And I think, yeah, like, Tim, maybe to your point, there's a lot of kind of low-hanging fruit
Larry Ogrodnek: where it's just like just even getting some of the information in people's heads in a structured
Larry Ogrodnek: way and even having, like, different processes defined in a structured way.
Larry Ogrodnek: Like, you get huge improvements from that.
Larry Ogrodnek: And this is kind of just like why we love technology, right?
Larry Ogrodnek: Is you have these building blocks and it's like, oh, now that we have this in a structured
Larry Ogrodnek: format, we can actually do these interesting things with it that we couldn't do before
Larry Ogrodnek: because it was just on someone's notepad or whatever.
Larry Ogrodnek: And so, yeah, you're right.
Larry Ogrodnek: I think there's still a lot of issues like that.
Larry Ogrodnek: And home building is for sure a big one.
Larry Ogrodnek: And yeah, it's been interesting.
Larry Ogrodnek: I mean, our main, actually, construction platform that manages our construction projects.
Larry Ogrodnek: So we have an interesting part of that, what you were saying, is it can be hard in underserved
Larry Ogrodnek: There are underserved areas to sort of have that domain expertise.
Larry Ogrodnek: And so you have to find a good partner.
Larry Ogrodnek: And one of the things we've done is we actually build the homes.
Larry Ogrodnek: So we're not just writing software for other builders to use, but we're building homes ourselves.
Larry Ogrodnek: And that's been a huge benefit because we have people building homes that we can sit down with and say, like, does this make sense?
Larry Ogrodnek: Like, does it not make sense?
Larry Ogrodnek: Like, why, why not?
Larry Ogrodnek: And, you know, we have to obviously push on both sides sometimes because we are trying to change things.
Larry Ogrodnek: Right.
Larry Ogrodnek: But that's been, I think it'd be almost impossible to do without.
Michael Kennedy: It's the dog fooding equivalent, the software dog fooding, right?
Michael Kennedy: Exactly.
Michael Kennedy: You're building.
Michael Kennedy: They're building, you're building.
Michael Kennedy: So then you can.
Larry Ogrodnek: I know.
Larry Ogrodnek: And it can be frustrating to get these phone calls like, why is this working?
Larry Ogrodnek: Like, you're going to make me late for this or that.
Larry Ogrodnek: But, you know, again, like those having those really strong partnerships, like, I don't know, it's critical to be able to get something that actually works.
Michael Kennedy: Yeah.
Michael Kennedy: Well, it sounds actually super exciting.
Michael Kennedy: I mean, I know you sold it.
Michael Kennedy: It's like, oh, we're just building.
Michael Kennedy: Just working in a building.
Michael Kennedy: No, this is cool.
Larry Ogrodnek: It's cool, yeah.
Larry Ogrodnek: And for the last couple of years, I've been doing a lot on our kind of more AI services team.
Larry Ogrodnek: And I'm not a machine learning researcher, but most of the work I've been doing has been around kind of productionizing that work and building services around it.
Larry Ogrodnek: And we've done really cool stuff like with, I mean, just like pricing models for the homes, which is kind of more traditional machine learning stuff.
Larry Ogrodnek: and then like schedule simulation stuff.
Larry Ogrodnek: And more recently, a lot of LLM-based stuff,
Larry Ogrodnek: both for kind of like, you know,
Larry Ogrodnek: rag style chat workflows.
Larry Ogrodnek: Like you can imagine you're in the field
Larry Ogrodnek: and you're like, you know,
Larry Ogrodnek: is this the right tile pattern?
Larry Ogrodnek: And maybe that's buried on like page 500
Larry Ogrodnek: of a Google spreadsheet or something like that.
Larry Ogrodnek: And being able to pull up quickly is huge.
Larry Ogrodnek: And now some of the stuff we're trying to do
Larry Ogrodnek: is more around automating schedule updates.
Larry Ogrodnek: So someone can kind of walk through a home
Larry Ogrodnek: and just, you know,
Larry Ogrodnek: do kind of stream of consciousness.
Larry Ogrodnek: Like, you know, this is the status of like this, like, you know, this is running late, whatever.
Larry Ogrodnek: And then we kind of, we have a multi-stage process, but we kind of, you know, turn the video into images and turn the transcription into notes and then try and like see what we can, what's in the photo, right?
Larry Ogrodnek: Like, is that the right tile pattern? Is that the right stove? And use LLMs for different parts of this process to kind of, you know, come up with recommendations at the end.
Larry Ogrodnek: like, oh, it actually looks like the drywall is totally installed and we can mark that as done
Larry Ogrodnek: or whatever. And, you know, having the automation is actually super helpful because having up-to-date
Larry Ogrodnek: schedules drives a lot of stuff, right? It's just like the efficiency of making sure people are on
Larry Ogrodnek: site and not delayed is huge. So that's been really-
Michael Kennedy: There's so many touch points of so many subcontractors and things, right? Like,
Michael Kennedy: when is the plumber going to be here? Well, they need to be here when the inspection for plumbing
Michael Kennedy: is here but that got you know like it's people who haven't gone through like somehow some kind of
Michael Kennedy: a house like i had a big home home improvement it's not quite the right word but like this big
Michael Kennedy: outside project with like a barbecue thing and so on done and wow after doing that i'm like there's
Michael Kennedy: i've got a lot of ideas for making this better this is bad no i know right and some of those
Larry Ogrodnek: delays are like super costly and it's funny because like a lot of things even in terms of
Larry Ogrodnek: like budgeting like right like if you buy too much material that's bad because you're wasting money
Larry Ogrodnek: But if you buy too little, that's actually even worse because like maybe, you know, you need more whatever lumber and maybe there's, you know, two weeks, you know, turnaround time to get it.
Larry Ogrodnek: And so and again, if you have to reschedule things like inspections, who knows when the next available one is, it might push the project out, you know, weeks.
Larry Ogrodnek: And so, yeah, there's a lot of interdependencies, a lot of, like you said, people and communication remains a very tricky problem.
Michael Kennedy: That's always one of the things.
Michael Kennedy: Well, it sounds awesome. And I'm also interested to see if your project at all touches on that. But let's dive in. Let's dive into PyView. Now, the first thing I want to point out here with PyView is it is not PyWebView, which has been around for three or four years at minimum. And I imagine that like a lot of people have seen this. PyWebView is a way to embed basically a browser into something that you can wrap as a desktop app. PyView, totally different. What's the elevator pitch on PyView?
Larry Ogrodnek: Totally different. Yeah. So the later pitch in PyView is basically, you know, it's one of those self-referential things. Hopefully I won't try and say Phoenix LiveView, but, you know, when you're building, when you're building modern web apps, and this is one of the things that I've seen, right, is, you know, if you want to have this rich interactivity, you want to have like a really rich client experience, maybe you reach for something like React or Vue. And, you know, those are great frameworks.
Larry Ogrodnek: But then you also have your backend server maybe managing the state and the database and those relationships and maybe talking to other servers.
Larry Ogrodnek: Maybe that's in Python or another language, whatever.
Larry Ogrodnek: And you kind of have to manage these two different pieces and they each have their own state.
Larry Ogrodnek: And it's very, you know, there can be a lot of complexity when you, yeah, the client is showing something slightly different than the server or vice versa and having to synchronize that state and keep them in sync.
Larry Ogrodnek: Plus, often there's a lot of glue code in between them, right?
Larry Ogrodnek: Like having to just go from the Python backend to the JavaScript frontend and back and forth.
Larry Ogrodnek: Even when things are in the same language, like I've worked on TypeScript apps where it's TypeScript backend and frontend,
Larry Ogrodnek: it's kind of rare that you actually share a lot of code for that layer.
Larry Ogrodnek: Things end up kind of drifting anyway and being different.
Larry Ogrodnek: And so PyView, the idea is, you know, what if you can have your backend server manage all your state, you're writing all your application logic in Python, you're just rendering HTML like you would for a static site.
Larry Ogrodnek: But when different interactions happen, like when you just click a button or enters a form field or, you know, different things happen on the friend end, we send an event to the server.
Larry Ogrodnek: The server processes the event and changes its state.
Larry Ogrodnek: So for example, maybe, I mean, this is a simple counter example, but you press plus on the counter.
Larry Ogrodnek: Then the server increments the count by one.
Larry Ogrodnek: It does a full re-render, but it does kind of a diff and says, oh, actually, looking at this full page, all I need to do is tell the front end to change zero to one.
Larry Ogrodnek: And so it efficiently sends that over a WebSocket connection.
Larry Ogrodnek: And I feel like there's already a lot there that maybe that wasn't the clearest description.
Larry Ogrodnek: But the idea is kind of more like, can we get SPA level interactivity, you know, including things like multi-user presence stuff, server push, really fast UI updates, you know, really fast local navigation, not doing full page reloads.
Larry Ogrodnek: But on the back end, our mental model really is something like a traditional static, you know, not static site generator, but like a static rendering thing.
Larry Ogrodnek: So I don't know.
Larry Ogrodnek: Was that clear?
Larry Ogrodnek: I think.
Michael Kennedy: Yes.
Michael Kennedy: It sounds like a lot.
Michael Kennedy: And what I think is cool about PyView
Michael Kennedy: is that it takes a lot of that
Michael Kennedy: and it just makes it automatic
Michael Kennedy: over a simple programming API, right?
Larry Ogrodnek: Yeah, exactly.
Larry Ogrodnek: So that's the thing is you don't have to think
Larry Ogrodnek: about a lot of this kind of plumbing.
Larry Ogrodnek: And this is the one kind of,
Larry Ogrodnek: I mean, we'll get into this more.
Larry Ogrodnek: Like this is something that I,
Larry Ogrodnek: an idea that I came up with.
Larry Ogrodnek: This is something that has been around
Larry Ogrodnek: for a little while on,
Larry Ogrodnek: in the Elixir side.
Larry Ogrodnek: It comes from this,
Larry Ogrodnek: this thing called Phoenix Live View.
Larry Ogrodnek: But yeah, you know,
Larry Ogrodnek: a framework actually can take care
Larry Ogrodnek: of a lot of this for us.
Larry Ogrodnek: And so as developers, all we really
Larry Ogrodnek: need to worry about is updating our state when events come in
Larry Ogrodnek: and rendering, doing a render of this.
Larry Ogrodnek: Given the state, what should we render to the back end?
Larry Ogrodnek: And the framework manages the Webseq connection.
Larry Ogrodnek: It manages the messages.
Larry Ogrodnek: It manages doing the diffing.
Larry Ogrodnek: And so we don't have to think about any of that.
Larry Ogrodnek: We really just need to think about how do I update my state
Larry Ogrodnek: and how do I render the website?
Larry Ogrodnek: And so it ends up being really powerful just having
Larry Ogrodnek: these very simple building blocks.
Larry Ogrodnek: And this is the kind of thing that--
Larry Ogrodnek: I mean, I'm not anti-JavaScript in general,
Larry Ogrodnek: but obviously we're using JavaScript on the front end.
Larry Ogrodnek: But by having this very generic JavaScript layer that just
Larry Ogrodnek: knows really simple things like, here's
Larry Ogrodnek: how I send messages when a button is pressed
Larry Ogrodnek: or when a text field changes.
Larry Ogrodnek: There's very simple building blocks,
Larry Ogrodnek: but you end up being this very powerful system
Larry Ogrodnek: when you bring them together.
Larry Ogrodnek: And you don't really have to write JavaScript
Larry Ogrodnek: for these interactions because, again, most of the things
Larry Ogrodnek: are very simple.
Larry Ogrodnek: It's like, you know, I need to change whatever.
Michael Kennedy: Your project is pretty new, which I'm hoping to shine a light on it because I think it's going to get a lot of attention.
Michael Kennedy: Out in the audience, Alessio points out that, hey, this is kind of like HTMX and Django with fragments, but over WebSockets.
Michael Kennedy: And yeah, I feel like it does have some HTMX vibes.
Michael Kennedy: And for those of you who haven't tried it, HTMX is like, you sprinkle just a couple of extra attributes on there.
Michael Kennedy: And then somehow behind the scenes,
Michael Kennedy: there's additional communication that you don't worry about.
Michael Kennedy: It's just say, oh, if somebody clicks this image,
Michael Kennedy: actually do this server thing and replace part of the page--
Michael Kennedy: maybe the image, maybe something else--
Michael Kennedy: with the server HTML response.
Michael Kennedy: How do you feel that PyView, Phoenix LiveView sort of
Michael Kennedy: relates to that and like Datastar, who I'm going to have on the--
Larry Ogrodnek: Yeah.
Larry Ogrodnek: No, I think that's right.
Larry Ogrodnek: I think that's a very thoughtful comment,
Larry Ogrodnek: because I think that is a lot of it.
Larry Ogrodnek: And if I had to think in terms of comparisons
Larry Ogrodnek: to different frameworks, I think doing something with HTMX
Larry Ogrodnek: probably is the closest comparison.
Larry Ogrodnek: Because again, it's HTML based.
Larry Ogrodnek: We are responding to events and wiring up to the server
Larry Ogrodnek: and processing them and sending back HTML fragments.
Larry Ogrodnek: I think the difference is that PyView
Larry Ogrodnek: is a little more structured, right?
Larry Ogrodnek: Because with HTMX, you have a lot more control,
Larry Ogrodnek: which can be a good thing.
Larry Ogrodnek: But it's a little more--
Larry Ogrodnek: you're kind of wiring up these things yourself
Larry Ogrodnek: to a certain extent, saying like, when you click on this,
Larry Ogrodnek: call this back end route and replace the contents of this
Larry Ogrodnek: element with the response from that.
Larry Ogrodnek: And on the back end, you're sending full HTML
Larry Ogrodnek: and things like that.
Larry Ogrodnek: So that's one difference.
Larry Ogrodnek: So yes, it is over WebSockets with PyView versus HTMX.
Larry Ogrodnek: The other thing is we do have this kind of diffing technology
Larry Ogrodnek: where we're only sending what actually changed.
Larry Ogrodnek: So I mean, we can go into more detail at some point
Larry Ogrodnek: about how the templating works.
Larry Ogrodnek: But for something like changing the encounter from 0 to 1,
Larry Ogrodnek: it's like we're really just sending back the 1.
Larry Ogrodnek: And obviously, as the page gets more complex,
Larry Ogrodnek: the diffs get more complex.
Larry Ogrodnek: But we're just sending the diffs.
Larry Ogrodnek: And again, the framework kind of handles--
Larry Ogrodnek: no, you don't have-- as a developer,
Larry Ogrodnek: you don't have to think about what part of the page
Larry Ogrodnek: do I update.
Larry Ogrodnek: And it's kind of encoded to a certain extent in your template.
Larry Ogrodnek: you know, it's kind of more hands-off.
Larry Ogrodnek: And so you do give up some flexibility,
Larry Ogrodnek: but then, you know, the framework kind of gets to handle
Larry Ogrodnek: a lot of things for you in a smoother integrated way,
Larry Ogrodnek: I would say.
Michael Kennedy: Just handles it.
Michael Kennedy: Yeah.
Michael Kennedy: With HTMLX, which I am a fan of,
Michael Kennedy: you have to think about every little piece.
Michael Kennedy: And you say, if somebody interacts with this part,
Michael Kennedy: then I want this action to happen.
Michael Kennedy: And then this thing over here, you know,
Michael Kennedy: these parts of the pages are going to be
Michael Kennedy: where the response of the server gets redirected back into.
Michael Kennedy: And it seems like it's more just handled a little bit here.
Michael Kennedy: Let's talk a little bit about Phoenix Live View,
Michael Kennedy: because while your project is pretty new, Phoenix Live View has,
Michael Kennedy: I don't know how old it is, a couple of years, it looks like,
Michael Kennedy: but it's got 6,700 stars.
Michael Kennedy: So it's a really solid foundation.
Michael Kennedy: And your project, what's the relationship between
Michael Kennedy: PyView and Phoenix LiveView?
Larry Ogrodnek: Right.
Larry Ogrodnek: So LiveView is obviously the inspiration for PyView.
Larry Ogrodnek: I think, you know, when I mean, I don't know, when I started thinking about like,
Larry Ogrodnek: you know, there's got to be a better way to building these kinds of apps in Python, I came
Larry Ogrodnek: across Phoenix LiveView and kind of really loved this model, especially just, I don't
Larry Ogrodnek: know, I kind of, I do like thinking this event kind of base system.
Larry Ogrodnek: And it seemed like, yeah, you get all the really nice things for free.
Larry Ogrodnek: So definitely was the inspiration.
Larry Ogrodnek: And then when I started working on PyView, I had the thought like, well, they've already kind of figured out a good model for how this works and how things fit together.
Larry Ogrodnek: And they already have a good client side story for implementing the client side component of this.
Larry Ogrodnek: So what I tried to do with PyView is actually use, you know, I ship their Phoenix LiveView front end client JavaScript is what you're running in a PyView app on your front end.
Larry Ogrodnek: And I kind of implemented a Python backend.
Larry Ogrodnek: So if you think about LiveView as a protocol, which to be clear, it is not.
Larry Ogrodnek: There's sort of just some, you know, have to do some reverse engineering of how things work.
Larry Ogrodnek: It's not really documented because I think, you know, on their end, it really is an internal implementation detail about how the front end communicates with the back end.
Larry Ogrodnek: But, you know, we get the, that really was a huge boost for me because I get to use their client JavaScript, which handles all the diffing.
Larry Ogrodnek: And again, a big part of it too is just kind of they do have a really nice design.
Larry Ogrodnek: So like you mentioned, Phoenix Live View has been around for a while.
Larry Ogrodnek: It's a very popular project.
Larry Ogrodnek: I think if you are in this ecosystem, so it's written in Elixir, which is a different programming
Larry Ogrodnek: language that runs on the Erlang virtual machine.
Larry Ogrodnek: And just to be clear, it's a totally great language.
Larry Ogrodnek: It has a lot of really cool features.
Larry Ogrodnek: It's nothing against Elixir.
Larry Ogrodnek: It's just that for different reasons, I wanted this paradigm in the Python world because I'm
Larry Ogrodnek: I'm working, you know, especially at work, I'm working on Python apps.
Larry Ogrodnek: And that's the kind of world I live in.
Larry Ogrodnek: And, you know, it's, it's, we can't change everything over to different languages.
Michael Kennedy: Just, you know, I'll throw it out there for you.
Michael Kennedy: You don't have to take the bullets.
Michael Kennedy: But I think functional programming languages are super interesting.
Michael Kennedy: They apply really well in certain to solve certain problems.
Michael Kennedy: And I know some people, it's the hammer for all nails.
Michael Kennedy: But for most people, functional programming is, it's just not what they're working in.
Michael Kennedy: you know, things where you can change variables and have state turn out to be more productive
Michael Kennedy: ways to write code, even if it maybe is not provably as correct or as thread safe or whatever,
Michael Kennedy: right?
Michael Kennedy: Like, so if most people are going to adopt it, most people are not using functional programming
Michael Kennedy: languages and Erlang in particular, Python happens to be more popular than Erlang.
Michael Kennedy: Yeah.
Larry Ogrodnek: Yeah.
Larry Ogrodnek: Well, there's different, I'll let you take those bullets, Michael.
Larry Ogrodnek: But yeah, I mean, look, different languages are good for different use cases, right?
Larry Ogrodnek: And but again, I think it's a really great idea that I thought, let me steal this.
Larry Ogrodnek: And so, yeah, this is something that was written by, I think, Chris McCord is like the author of Live View.
Larry Ogrodnek: And it's been around, yeah, for a long time.
Larry Ogrodnek: It's gone through different iterations.
Larry Ogrodnek: But yeah, it's incredibly popular in that ecosystem.
Larry Ogrodnek: And yeah, they've done, I think, really great, great things with it.
Michael Kennedy: Yeah.
Michael Kennedy: And let's I just want to give a little shout out.
Michael Kennedy: If you go to the Phoenix Live View GitHub, which, of course, I'll link in the show notes, there's a live demo on Fly that you can check out.
Michael Kennedy: And there's also a two minute video.
Michael Kennedy: Watch the two minute video.
Michael Kennedy: It really shows like, okay, this is a quite an interesting and quite capable technology.
Michael Kennedy: It might sound like, oh, you can't do very much with this because I don't know.
Michael Kennedy: It seems like it's only built to make a few things easy.
Michael Kennedy: I, after watching what he built there with this app with Phoenix Live View, I was impressed.
Michael Kennedy: It's quite flexible.
Larry Ogrodnek: No, for sure.
Larry Ogrodnek: And there's a lot of, I think it took a lot of work to get there too, right?
Larry Ogrodnek: Just to give, you know, them a little more, a lot of credit, like, because a lot of the
Larry Ogrodnek: I mean, it's interesting because like once you take this approach to being having everything over WebSockets, well, then actually it's pretty great because it opens up a lot of things that could be hard, like things like, yeah, like presence, like knowing different users that are, you know, on the same documenter page as you or like server pushes.
Larry Ogrodnek: You kind of get a lot of that stuff, not, you know, for free, but it's easy when that's kind of your base layer is everything over WebSockets.
Larry Ogrodnek: But then some things like file uploads, like as part of this, they invented a way to kind of do file uploads over WebSockets.
Larry Ogrodnek: Oh, that's interesting.
Larry Ogrodnek: Yeah, because how do you do that, right?
Larry Ogrodnek: And WebSecrets do support both like text and binary messages.
Larry Ogrodnek: So it's not as crazy as you would think, but there is like a limit to, you know, you have to kind of, you know, chunk it and stuff like that.
Larry Ogrodnek: But so it supports that.
Larry Ogrodnek: And, you know, I mean, again, we can talk more about file, but there are other options for also going like direct to S3 or, you know, different things.
Larry Ogrodnek: But, yeah, you know, a lot of work has gone into this and including around the optimization.
Larry Ogrodnek: Like, what is that message format?
Larry Ogrodnek: Like, how do you send minimal diffs for not just things like, you know, simple template changes?
Larry Ogrodnek: but when you have lists or components or maybe you have huge lists of things,
Larry Ogrodnek: how do you efficiently manage that on both the server side and the client side? And so I think
Larry Ogrodnek: there's a lot of great ideas for dealing with this that were pioneered by Phoenix Live View that I
Larry Ogrodnek: get to come along and kind of just steal. That's cool. Here's the downtime version.
Larry Ogrodnek: Yeah, exactly. And I think that's kind of was like a lot of the focus early on was trying to
Larry Ogrodnek: to stick to this just because, again, PyView, like you said, it is very early days and it is just
Larry Ogrodnek: kind of like a personal side project. Although I am using it at my day job for a couple of production
Larry Ogrodnek: apps now, which has been fantastic. But as a single developer with a Python web framework as a side
Larry Ogrodnek: project, it was great to have a little bit of a roadmap on if I follow these patterns, I'm probably
Larry Ogrodnek: going to end up in a good place. And I did. Of course, I did try and make things more Pythonic
Larry Ogrodnek: where I could.
Larry Ogrodnek: So PyView is very heavily typed.
Larry Ogrodnek: So we're using obviously Python types for everything.
Larry Ogrodnek: Whereas Elixir, I think they're adding types now.
Larry Ogrodnek: It's been an ongoing thing to add some gradual typing
Larry Ogrodnek: like Python has done.
Larry Ogrodnek: But Python is a little further along
Larry Ogrodnek: in terms of the typing story there.
Larry Ogrodnek: And I think over time, maybe we'll diverge a little bit
Larry Ogrodnek: in terms of making the APIs more Pythonic
Larry Ogrodnek: to the extent anything is not.
Larry Ogrodnek: But yeah, for sure, having this kind of at least
Larry Ogrodnek: this core level protocol has been useful to follow.
Michael Kennedy: Yeah, they've kind of worked out how the exchange works
Michael Kennedy: and all those different things.
Michael Kennedy: You're like, OK, let me do the--
Larry Ogrodnek: Yeah, and I sort of have a roadmap to like,
Larry Ogrodnek: oh, these are the problems you're going to get into.
Larry Ogrodnek: Because that's when I first started PyView.
Larry Ogrodnek: So I did start it a couple years ago, just as a very--
Larry Ogrodnek: but again, very sparse.
Larry Ogrodnek: Like, can I get anything to show up on the page over Websockets?
Larry Ogrodnek: And then kind of iterated.
Larry Ogrodnek: And it's interesting to--
Larry Ogrodnek: when I started the first version of the LiveView client
Larry Ogrodnek: JavaScript I used, then figuring out
Larry Ogrodnek: what changed between that and the next version
Larry Ogrodnek: and the next version and the next version.
Larry Ogrodnek: You get to see the gradual progression of like,
Larry Ogrodnek: oh, these are some problems we're going to run into,
Larry Ogrodnek: because they've sort of addressed that in this future version.
Larry Ogrodnek: But I still have to deal with it,
Larry Ogrodnek: but I'll get there at some point.
Michael Kennedy: Yeah, go look at the closed GitHub issues,
Larry Ogrodnek: and you're like, whoa, there's a lot of conversation
Larry Ogrodnek: around this one.
Michael Kennedy: Yeah.
Michael Kennedy: Interesting.
Michael Kennedy: So I think a nice thing to do for people
Michael Kennedy: would be to just do a quick walkthrough,
Michael Kennedy: because you've got a nice little getting started thing.
Michael Kennedy: You've just got to be careful that most people are listening, not seeing.
Michael Kennedy: But let's talk through, let's maybe talk through what it means to create
Michael Kennedy: just like a real simple program in PyView.
Larry Ogrodnek: Sure.
Larry Ogrodnek: Yeah, so I do, yeah, so the documentation is something, again,
Larry Ogrodnek: it's a work in progress, but I did try to get to start getting some things together.
Larry Ogrodnek: So yeah, I do have a cookie cutter project.
Larry Ogrodnek: And I think, you know, the first one in documentation,
Larry Ogrodnek: if you check out the cookie cutter project,
Larry Ogrodnek: It gives you like a very quick project setup.
Larry Ogrodnek: Sorry, I'm just going to go.
Michael Kennedy: Yeah, for people who don't know,
Michael Kennedy: like Cookie Cutter is a way to take
Michael Kennedy: a pre-structured set of source files
Michael Kennedy: of all varieties, even images and other things,
Michael Kennedy: and say, I'm going to ask you a few questions,
Michael Kennedy: I'm going to do a little text replace,
Michael Kennedy: and then I'm going to generate that structure for you.
Michael Kennedy: So a very nice way to kind of go like,
Michael Kennedy: all right, we got everything set up
Michael Kennedy: for you to get started, right?
Larry Ogrodnek: Right, exactly.
Larry Ogrodnek: Because I really wanted to get, you know,
Larry Ogrodnek: And part of the thought with PyView
Larry Ogrodnek: is I really do want it to be super easy to get started,
Larry Ogrodnek: not just for other people, but also for myself.
Larry Ogrodnek: Like, if I have a new idea of something,
Larry Ogrodnek: it's like I want to go from zero to one super quickly.
Larry Ogrodnek: And that's kind of been part of the motivation.
Larry Ogrodnek: And so this cookie cutter is a great way to--
Larry Ogrodnek: so you check out the cookie cutter,
Larry Ogrodnek: and then you basically have a working example right away
Larry Ogrodnek: with just the simple counter.
Larry Ogrodnek: And so this example uses poetry for dependency management.
Larry Ogrodnek: So if you do poetry install, and then--
Larry Ogrodnek: It also includes Just, which is a command line runner.
Larry Ogrodnek: So Just, it's kind of like--
Larry Ogrodnek: I don't know if you've talked about this before,
Larry Ogrodnek: but if anyone's ever used Makefiles or things
Larry Ogrodnek: like that for doing common project tasks,
Larry Ogrodnek: Just is a tool like that, but specifically written
Larry Ogrodnek: for these types of things.
Larry Ogrodnek: And so if you use Makefiles, you know
Larry Ogrodnek: there's a lot of tricks you have to do
Larry Ogrodnek: to kind of get it to work in the way you want
Larry Ogrodnek: versus as a build tool.
Larry Ogrodnek: And so Just kind of works the right way a lot easier,
Larry Ogrodnek: and it's something that kind of--
Larry Ogrodnek: Yeah, exactly.
Larry Ogrodnek: I'm using more and more.
Larry Ogrodnek: So if you check out the-- if you run the cookie cutter,
Larry Ogrodnek: run poetry install, and then run just,
Larry Ogrodnek: it'll tell you to open localhost to 8,000 in your browser.
Larry Ogrodnek: And you'll have a counter example up and running already.
Larry Ogrodnek: And the kind of interesting thing,
Larry Ogrodnek: if you want to play along with this more--
Larry Ogrodnek: and I do have this in the docs in terms of what's going on here.
Larry Ogrodnek: But it's a really good example to kind of open up
Larry Ogrodnek: in Firefox or Chrome, and then open the developer tools
Larry Ogrodnek: and the network tab.
Larry Ogrodnek: And when you load the page, what you'll see is--
Larry Ogrodnek: and this is kind of the Live View model, right?
Larry Ogrodnek: There's an initial page load, which is like the server--
Larry Ogrodnek: so it goes to your view, and it runs your templating logic.
Larry Ogrodnek: And it returns that as just straight HTML,
Larry Ogrodnek: like a normal web page.
Larry Ogrodnek: So if you had turned off JavaScript,
Larry Ogrodnek: you'd still get the page back.
Larry Ogrodnek: But if you have JavaScript on, which is obviously intention,
Larry Ogrodnek: then what happens is included in that initial page load
Larry Ogrodnek: is some JavaScript that comes back.
Larry Ogrodnek: - Oh, obviously you have it open, Michael.
Larry Ogrodnek: Yeah, so if you, if you, yeah, exactly.
Larry Ogrodnek: So the HTML is right there.
Larry Ogrodnek: So that's like the full HTML of the page.
Larry Ogrodnek: So yeah, if you had turned off JavaScript,
Larry Ogrodnek: that part would still work.
Larry Ogrodnek: But then if you click on the,
Larry Ogrodnek: do you see in there a WebSocket connection in your--
Michael Kennedy: - Oh yeah, somewhere, socket, yep.
Larry Ogrodnek: - So if you click on that,
Larry Ogrodnek: you can see the messages back and forth.
Larry Ogrodnek: So when you click on the messages tab there, yeah.
Larry Ogrodnek: And so you can see--
Michael Kennedy: - Interesting.
Larry Ogrodnek: - Right.
Michael Kennedy: - Yeah, so there's a whole set of examples,
Michael Kennedy: or live interactive examples,
Michael Kennedy: people can just go to pyv.rocks and click live examples and do this to see it right yeah yeah
Larry Ogrodnek: okay this is super cool yeah that message you have right there it says diff zero one so like zero is
Larry Ogrodnek: like the kind of slot in the template and so it says now that should be one so you click you know
Larry Ogrodnek: plus again then the new message will be diff you know whatever and you can see this message says
Larry Ogrodnek: event increment so this is what goes to your back end is you're getting a click event for increment
Michael Kennedy: and you're sending back a response um and so yeah it's so does it like uh instrument your html with
Michael Kennedy: of identifiers or something like that to then be able to do this?
Larry Ogrodnek: Yeah, and so that was one of the things that I've been so unhappy with for a while
Larry Ogrodnek: with PyView is because when I first started doing this, I was like, okay, I want a nice
Larry Ogrodnek: HTML templating language, right? Or maybe even it'd be better if it was pluggable,
Larry Ogrodnek: if you could use whatever templating language you want. But the problem is, most Python templating
Larry Ogrodnek: languages, the input is your template and some data, and the output is a string.
Larry Ogrodnek: And for this, what we're trying to produce is like a render tree.
Larry Ogrodnek: And so really the mental model is a lot more like t-strings, if people are familiar with t-strings, where you have like a template, right?
Larry Ogrodnek: Your HTML template, and it's separated into static parts, like strings, and dynamic parts, like things to be evaluated.
Larry Ogrodnek: And that's kind of the live view model.
Larry Ogrodnek: And the pie view model is like, basically, we take a template and we convert it into a list of statics and dynamics.
Larry Ogrodnek: And each dynamic, like each evaluation spot itself
Larry Ogrodnek: has static parts and dynamic parts.
Larry Ogrodnek: And so we have to take an HTML template
Larry Ogrodnek: and turn it into this render tree.
Larry Ogrodnek: And so again, this is like a huge pain point
Larry Ogrodnek: because I couldn't find a templating language that would
Larry Ogrodnek: let me kind of get that level of control.
Larry Ogrodnek: And maybe there is one, and I'm not familiar with it.
Larry Ogrodnek: Or maybe there is a way to get to these internals.
Larry Ogrodnek: I'm not familiar with it.
Larry Ogrodnek: But what I am doing was there is this library called IBIS,
Larry Ogrodnek: which someone had wrote an open source as a tutorial
Larry Ogrodnek: on how to write your own templating language.
Larry Ogrodnek: And so it's very similar to Jinja 2, but a lot simpler.
Larry Ogrodnek: And so that was the initial templating language for PyView
Larry Ogrodnek: because I could hack it just enough to get both HTML
Larry Ogrodnek: and also this more template-like view that I need.
Larry Ogrodnek: This is one of the things that I'm
Larry Ogrodnek: very excited about with now that we have t-strings in 3.14
Larry Ogrodnek: is that I think that model just maps so directly to this.
Larry Ogrodnek: And I'm hopeful that we'll have a lot of different rendering
Larry Ogrodnek: libraries or templating language for HTML.
Larry Ogrodnek: Like I know there's already a good one,
Larry Ogrodnek: or it's a work in progress called T-DOM
Larry Ogrodnek: that people are working on to make t-strings more HTML--
Larry Ogrodnek: not friendly, not that they're not already,
Larry Ogrodnek: but there are certain things you want.
Larry Ogrodnek: Like obviously, you want to be able to just
Larry Ogrodnek: automatically scaping of user input so it's not malicious.
Larry Ogrodnek: Maybe even merging things in HTML attributes.
Larry Ogrodnek: Like there's nicer things you can kind of do when you're thinking about the HTML use case, right?
Larry Ogrodnek: But I like having like a template as like the core building block, because if you can get to a template, that's super easy to turn into like the structure we need for a live view.
Larry Ogrodnek: And I imagine there'll be multiple ways to do that in the future, you know?
Michael Kennedy: Yeah, very interesting.
Michael Kennedy: It sounds a little bit like almost a concrete syntax tree of the DOM that you've got to like, okay, we've got to understand all the pieces and what parts get pushed down.
Michael Kennedy: Like from here down is the chunk we got to send down because this part changed.
Larry Ogrodnek: Exactly, exactly.
Larry Ogrodnek: And yeah, like you said, it is a little bit like that.
Larry Ogrodnek: I mean, because there's, you know, it's not even as simple as like this,
Larry Ogrodnek: because there is like some special handling for things like components, you know,
Larry Ogrodnek: are sort of managed slightly differently.
Larry Ogrodnek: And then even kind of that, like if you had, this is like not a great example,
Larry Ogrodnek: but if you had multiple counters on your page, maybe you'd want to optimize like,
Larry Ogrodnek: well, they really just need one set of static content for all the counters.
Larry Ogrodnek: even though we kind of want to manage them separately.
Larry Ogrodnek: And so there's different optimizations like that that are done.
Larry Ogrodnek: But yeah, it is.
Larry Ogrodnek: Everything comes from this kind of render tree
Larry Ogrodnek: is how we can do those diffs.
Michael Kennedy: Okay.
Michael Kennedy: Let's talk through these examples a tad more.
Michael Kennedy: And we don't necessarily need this going.
Michael Kennedy: But, you know, back to the Alessio pointed out,
Michael Kennedy: the HTMX example.
Michael Kennedy: If you go to the HTMX website,
Michael Kennedy: there's a bunch of cool live examples there as well.
Michael Kennedy: And literally in the page,
Michael Kennedy: Carson has put it such that you see these exchanges
Michael Kennedy: as you interact with it.
Michael Kennedy: You know what I mean?
Michael Kennedy: That's how significant that is.
Michael Kennedy: So maybe let's pick out just a couple of the examples here
Michael Kennedy: that we could talk through that you think are worth pointing out.
Michael Kennedy: Some of the capabilities are inspiring, but not insane.
Michael Kennedy: I don't know.
Larry Ogrodnek: JOHN MCWHORTER: Sure.
Larry Ogrodnek: I mean, a really quick one is this volume control,
Larry Ogrodnek: like the third one up at the top, which
Larry Ogrodnek: it's not a super interesting example.
Larry Ogrodnek: But just the thing about it is that it has keyboard control.
Larry Ogrodnek: So you can see it's super easy to just do keyboard bindings.
Larry Ogrodnek: And this is one of those things where like--
Larry Ogrodnek: - Just arrow keys.
Larry Ogrodnek: - Yeah, I mean, which seems like a small thing.
Larry Ogrodnek: - I'm not using the mouse, right?
Larry Ogrodnek: There it goes.
Larry Ogrodnek: - Seems like a small thing,
Larry Ogrodnek: but it's one of those things when you start to dive into,
Larry Ogrodnek: right, like, you know, even like, you know,
Larry Ogrodnek: sometimes you might wonder like, you know,
Larry Ogrodnek: why are there all these different HTML component libraries
Larry Ogrodnek: that do things like a button?
Larry Ogrodnek: It's just like, well, you know,
Larry Ogrodnek: when you wanna think about things like accessibility
Larry Ogrodnek: and different languages and blah, blah, blah,
Larry Ogrodnek: like there's actually a lot that goes into it.
Larry Ogrodnek: And so something like keyboard bindings
Larry Ogrodnek: is something I honestly would never take the time
Larry Ogrodnek: to add to all that before because it seems like such an undertaking,
Larry Ogrodnek: even though you could say, oh, it's simple.
Larry Ogrodnek: You just add event handlers to all your things and blah, blah, blah.
Larry Ogrodnek: But yeah, it was just slightly out of adding to an example project.
Larry Ogrodnek: But now it's because it's built into the framework.
Larry Ogrodnek: It's super easy, and it gets treated the same as any other event.
Larry Ogrodnek: So pressing a key up or key down, send it to the event,
Larry Ogrodnek: just clicking the button.
Larry Ogrodnek: And so it's one of those things.
Larry Ogrodnek: It's a simple example, but it's--
Larry Ogrodnek: JOSHUA SHARFSTEIN: Yeah, so let me describe it for listeners.
Michael Kennedy: So you've got this progress bar looking thing.
Michael Kennedy: That's the volume control, like, you know, your standard macOS looking thing.
Michael Kennedy: And it's got a mute button, a max volume, an up and down button.
Michael Kennedy: And these are like buttons that, you know, you might be used to, but also you can just,
Michael Kennedy: you know, use the arrow keys and it's just as if you're clicking the button and it all
Michael Kennedy: updates even with like probably one of those CSS transitions to make it feel a little animated
Michael Kennedy: instead of jumping.
Michael Kennedy: Yeah.
Michael Kennedy: Looks really nice.
Michael Kennedy: So what about the source?
Michael Kennedy: I think there's a couple interesting things here.
Michael Kennedy: First of all, the volume.html, this looks Tailwind.
Michael Kennedy: Is that right?
Larry Ogrodnek: Yeah, this is using Tailwind.
Larry Ogrodnek: Yeah.
Larry Ogrodnek: Okay.
Larry Ogrodnek: Yeah.
Larry Ogrodnek: It's interesting.
Larry Ogrodnek: I feel like it's one of those things where my first pass of this example's website used
Larry Ogrodnek: almost no HTML CSS and was like super ugly.
Larry Ogrodnek: But I kind of wanted the focus to be on like what is the, like what is like the really,
Larry Ogrodnek: what are you really writing versus like what is, you know.
Larry Ogrodnek: But I kind of gave in and used Talens because it looks a lot nicer.
Larry Ogrodnek: It looks more professional, something people would want to pick up, right?
Michael Kennedy: Yeah, I think this gets lost sometimes in different projects because, you know, I look at a lot of people send me projects all the time.
Michael Kennedy: And like, hey, do you think this is what we're talking about in various venues or whatever?
Michael Kennedy: Having something that looks like, oh, I wish my app looked like that or it did like that is highly inspiring.
Michael Kennedy: It's not, you know, if you had like, hey, look, we have all of our live demos and they're exactly like 1993 web view, like appearance, but see how easy the program is.
Michael Kennedy: I know if you look at this, the source, it's full of, you know, like P8 for padding eight and, you know, such and such.
Michael Kennedy: It's worth it.
Michael Kennedy: Right.
Michael Kennedy: It's so worth it.
Michael Kennedy: And the HTML is just pure HTML, except for you have these sort of attribute-driven things, right?
Michael Kennedy: Right, exactly.
Michael Kennedy: Can we talk about how is the HTML different then?
Larry Ogrodnek: That's exactly it, yeah.
Larry Ogrodnek: So for this example, the difference is, right, for a button, we have this phx click attribute,
Larry Ogrodnek: which is what tells, you know, wires up with Phoenix Live View that when someone clicks on this,
Larry Ogrodnek: we should send this event call.
Larry Ogrodnek: So the first one says phx click equals down.
Larry Ogrodnek: And so when someone clicks on that button, we send an event to the server that just says,
Larry Ogrodnek: like, you know, click down.
Larry Ogrodnek: And there's also this PHS, PHX window key down and PHX key.
Larry Ogrodnek: So, you know, basically we're sending like a key update, you know, for this arrow down
Larry Ogrodnek: is like one of the keys.
Larry Ogrodnek: And so these parts are not something that I, again, this is like just the straight Phoenix,
Larry Ogrodnek: like if you're an Elixir app, it would work exactly the same way.
Larry Ogrodnek: You could take this HTML and run it on Elixir app.
Larry Ogrodnek: And if you had the Elixir backend, it would work exactly the same way.
Larry Ogrodnek: So that side looks exactly the same.
Michael Kennedy: Yeah, I mean, what's the value in renaming that to PYW or something?
Larry Ogrodnek: Yeah, I know.
Larry Ogrodnek: And actually, I think you could.
Larry Ogrodnek: I think they do have it configurable with the client JavaScript
Larry Ogrodnek: where you can do a different specifier if you wanted to.
Larry Ogrodnek: But it's kind of nice this way.
Larry Ogrodnek: I mean, I think the other thing is, too, in the age of LLMs,
Larry Ogrodnek: and just even examples, at this point,
Larry Ogrodnek: there's a ton more Phoenix Live View code than there is
Larry Ogrodnek: And so if you find a good LiveView example,
Larry Ogrodnek: it's like you can get it to work in PyView hopefully.
Larry Ogrodnek: - Yeah, that's interesting.
Michael Kennedy: So in a sense, the front end stuff is API compatible
Michael Kennedy: with both backends maybe.
Michael Kennedy: Is that it?
Larry Ogrodnek: - Yeah, sort of.
Larry Ogrodnek: I mean, like, yeah, and like conceptually,
Larry Ogrodnek: I mean, I think that the thing is the Phoenix LiveView
Larry Ogrodnek: has a different templating language.
Larry Ogrodnek: So things like loops or conditionals
Larry Ogrodnek: look totally different, right?
Larry Ogrodnek: So you might be able to pull up an example and go,
Larry Ogrodnek: I see how I'll do it here, but it's not identical.
Larry Ogrodnek: Right, exactly.
Larry Ogrodnek: Or if you see something in an example where it's just like,
Larry Ogrodnek: I'm trying to do a form, but my PHX update isn't firing,
Larry Ogrodnek: it's like it's probably the same solution in both places.
Michael Kennedy: Got it.
Michael Kennedy: So then you've got the HTML side, which is pretty interesting.
Michael Kennedy: Tell us about how this-- what do we write over here on--
Michael Kennedy: Yeah, so--
Michael Kennedy: The data exchange looks like-- sorry.
Michael Kennedy: The data exchange looks like you're exchanging data classes,
Michael Kennedy: like the DTO sort of API aspect?
Larry Ogrodnek: Yeah, exactly.
Larry Ogrodnek: So, well, you can, yeah, so each live view, like page,
Larry Ogrodnek: is basically like you would type it to a specific,
Larry Ogrodnek: you know, I call it a context,
Larry Ogrodnek: like which is like what,
Larry Ogrodnek: basically what's going into your template.
Larry Ogrodnek: And so you can do, I mean, it doesn't have to be,
Larry Ogrodnek: I like using data classes.
Larry Ogrodnek: It can be a data class, it can be a type dict,
Larry Ogrodnek: it could be a Pydantic class,
Larry Ogrodnek: it could probably just be a regular dict.
Larry Ogrodnek: I don't know that I've ever tried that,
Larry Ogrodnek: but I think that should work.
Larry Ogrodnek: But it's just really just for the typing.
Larry Ogrodnek: And it's what we'll get past here in template.
Larry Ogrodnek: And then so maybe it's worth talking through.
Larry Ogrodnek: Like there are these sort of different lifecycle components.
Larry Ogrodnek: And so with your view, the first thing that gets called
Larry Ogrodnek: is there's this mount command.
Larry Ogrodnek: And that gets called any time--
Larry Ogrodnek: I mean, when your view gets instantiated.
Larry Ogrodnek: So when someone visits the page, we're
Larry Ogrodnek: going to create an instance of your class, your LiveView class.
Larry Ogrodnek: And mount will get called with the socket,
Larry Ogrodnek: which is probably going to be more detailed than that,
Larry Ogrodnek: but that's kind of like your interface to the communication.
Larry Ogrodnek: It's not the web socket necessarily.
Larry Ogrodnek: It's more like how you interoperate with the system.
Larry Ogrodnek: And then also the session.
Larry Ogrodnek: So if you want to copy stuff over from the HTTP session,
Larry Ogrodnek: like user information or whatever,
Larry Ogrodnek: you can copy that over in the mount to your data.
Larry Ogrodnek: Then after that-- and it actually gets called--
Larry Ogrodnek: well, I'll talk about that later.
Larry Ogrodnek: But then after that, there's an optional--
Larry Ogrodnek: it's not shown in this example, but there's
Larry Ogrodnek: optional like handle params change, which gets called with path parameters or URL parameters.
Larry Ogrodnek: And the reason that's separate is because your class might get just instantiated once
Larry Ogrodnek: on when the page is viewed, but you might have like programmatic navigation that's not real
Larry Ogrodnek: navigation. It's like JavaScript navigation where maybe for things like filter options or
Larry Ogrodnek: pagination options, you want to put those in the URL so that it's kind of bookmarkable and shareable.
Larry Ogrodnek: you don't want to do a full page reload and so anytime those get changed including on the initial
Larry Ogrodnek: page load we'll call a handle prams method and you don't have to implement that if you don't care
Michael Kennedy: about it um so that gets called in this case a volume is the volume it doesn't matter where
Larry Ogrodnek: the volume exactly yeah but you might want to like be able to bookmark like this is a good volume or
Larry Ogrodnek: whatever and i think the counting example does does have that just to kind of show how it would work
Michael Kennedy: um i see so in that sense you get a bit of a deep linking into it exactly that's cool yeah okay yeah
Larry Ogrodnek: Yeah, and again, it takes advantage of this kind of like JavaScript navigation that you can initiate from the front end or from the back end.
Larry Ogrodnek: Like on the front end, you can initiate like a navigation transition that will like basically tell the back end, hey, change your prams to this.
Larry Ogrodnek: And the browser takes care of like reading the prams and changing the, or the back end takes care of reading the prams and changing the state.
Larry Ogrodnek: Or on the back end, you can also tell the front end like, oh, hey, because you did this, I want you to change the URL to be blah, blah, blah.
Larry Ogrodnek: And here's what the new URL should be.
Larry Ogrodnek: So you can do it both ways.
Larry Ogrodnek: And then the render method gets called.
Larry Ogrodnek: And it's not shown here because the base class, basically,
Larry Ogrodnek: for the render method, it looks for a template
Larry Ogrodnek: file called whatever.
Larry Ogrodnek: This is volume.py.
Larry Ogrodnek: So it looks for volume.html.
Larry Ogrodnek: And it uses that as your template.
Larry Ogrodnek: It also will look to see if there's a volume.css.
Larry Ogrodnek: And it will just inject that in as the CSS for this.
Larry Ogrodnek: It exists.
Larry Ogrodnek: But if you wanted to override render, you can.
Larry Ogrodnek: And that's how the T-Street rendering works,
Larry Ogrodnek: is you basically do provide a render method
Larry Ogrodnek: that returns a T string.
Larry Ogrodnek: So after all that is done--
Larry Ogrodnek: so that actually happens twice.
Larry Ogrodnek: It happens once for the HTML render,
Larry Ogrodnek: and then it happens again for the LiveView render.
Larry Ogrodnek: And those are handled separately,
Larry Ogrodnek: partially because that's how Phoenix LiveView does it,
Larry Ogrodnek: but also because some things are different.
Larry Ogrodnek: For the initial HTML render, some things are not available.
Larry Ogrodnek: You can't do Pub/Sub stuff to subscribe to channels.
Larry Ogrodnek: You can't do scheduling stuff.
Larry Ogrodnek: It's a little bit more limited to what you can do.
Larry Ogrodnek: But anyway, that's a separate step.
Larry Ogrodnek: And then after render, if an event comes in,
Larry Ogrodnek: this handle event gets called.
Larry Ogrodnek: And what you're showing here for the volume control
Larry Ogrodnek: is kind of like my V1 of the event method that basically just
Larry Ogrodnek: takes an event.
Larry Ogrodnek: So there's one method called handle event
Larry Ogrodnek: that takes the event and a payload, which
Larry Ogrodnek: is like a dict of the options.
Larry Ogrodnek: Then you have the socket.
Larry Ogrodnek: And so you can see here, it's just a bunch of if else.
Larry Ogrodnek: It's like if the event is key update,
Larry Ogrodnek: then just take the key as the event name.
Larry Ogrodnek: If it's on or off, change the--
Larry Ogrodnek: If it's off or they hit the left arrow, then set the volume to 0.
Larry Ogrodnek: If it's on or they hit the right arrow, set the volume to 100.
Larry Ogrodnek: And then there's some stuff that just bound the volume at the end.
Larry Ogrodnek: And so that's all you do is you basically--
Larry Ogrodnek: this handle event method gets called.
Larry Ogrodnek: You're updating your state.
Larry Ogrodnek: And then after this gets called, automatically,
Larry Ogrodnek: your render method gets called again.
Larry Ogrodnek: And basically, you're just re-rendering with the new state.
Larry Ogrodnek: And then again, on the back end, we're figuring out,
Larry Ogrodnek: Like, okay, last time you rendered this tree,
Larry Ogrodnek: now you're rendering this tree.
Larry Ogrodnek: What changed?
Larry Ogrodnek: I'm just going to send what changed.
Michael Kennedy: It looks very, I don't know, view or data binding like in here.
Michael Kennedy: So when things start up, you say the context of this thing is an instance of the volume class.
Michael Kennedy: And then all you write in your code is like socket.context.volume equals the various,
Michael Kennedy: you know, plus equals 10, minus equals 10.
Michael Kennedy: Exactly.
Michael Kennedy: And somehow, iView says, okay, I've wrapped this thing in some kind of responsive or something that detects the changes, right, somehow?
Larry Ogrodnek: Right. Well, yeah, actually, yeah, I mean, we're not even that smart right now.
Larry Ogrodnek: I mean, we could be, and I think FinisLiveView is a little smarter about it, where they do wrap and kind of see if they, but like for this, basically, we just always render.
Michael Kennedy: I see. So you re-render the page and just go, what is actually different about, oh, I see, when I re-rendered with new data, then the volume value changes.
Michael Kennedy: Exactly.
Larry Ogrodnek: But it is really nice because like you're saying,
Larry Ogrodnek: it's like you don't really--
Larry Ogrodnek: like your application logic becomes really simple
Larry Ogrodnek: because it's really just, yeah, I update my state.
Larry Ogrodnek: And then I know how to render my state object.
Larry Ogrodnek: And I don't really care about whatever.
Larry Ogrodnek: And even this handle event method, it's not really--
Larry Ogrodnek: I mean, I don't know.
Larry Ogrodnek: It feels like it'd be a little bit of a stretch
Larry Ogrodnek: to call it stateless because you're mutating state.
Larry Ogrodnek: But at the same time, you don't really
Larry Ogrodnek: care where this state object came from.
Larry Ogrodnek: It's like, given this event, how would I
Michael Kennedy: this state. Yeah, and it's got a very strong view.js feel like I just changed the properties of the
Michael Kennedy: thing and something makes it happen that it goes back to everywhere this value is used. It changes.
Larry Ogrodnek: Exactly. And that's really how it works. I mean, that's the kind of cool thing, you know, where
Larry Ogrodnek: we're talking about HTMX, where, you know, you have to be really intentional about like, OK,
Larry Ogrodnek: like how do I want to segment, you know, what I'm changing? And, you know, when I do this, I know I
Larry Ogrodnek: want to change this part of the render, this part of the render. And with this, you don't really have
Larry Ogrodnek: to think about it, right? Like you just change what you want to change. And the part of the template
Larry Ogrodnek: that needs to change will naturally change
Larry Ogrodnek: because we're treating it as this diff operation.
Michael Kennedy: Yeah, yeah, cool.
Michael Kennedy: Let's do one more example, something that kind of shows
Michael Kennedy: off what's possible.
Larry Ogrodnek: OK, well, gosh, there's two things I'd want to show.
Larry Ogrodnek: But we could do the maps thing, which
Larry Ogrodnek: is just a way how to integrate with JavaScript,
Larry Ogrodnek: and then also maybe one of the newer things,
Larry Ogrodnek: or maybe the T Street version of the counter, just to--
Larry Ogrodnek: yeah, so we'd look at the maps one.
Larry Ogrodnek: And so this is very simple, but this is a thing that--
Larry Ogrodnek: I think the thing with like frameworks with PyView
Larry Ogrodnek: and other frameworks is I think maybe people try to bucket
Larry Ogrodnek: into like, oh, you hate JavaScript or whatever.
Larry Ogrodnek: And like, no, I don't hate JavaScript.
Larry Ogrodnek: JavaScript's great at doing JavaScript things.
Larry Ogrodnek: And you do need to integrate with JavaScript a lot of the times.
Larry Ogrodnek: And there's a lot of really great, rich, interactive JavaScript
Larry Ogrodnek: things that wouldn't really make sense to do in the server.
Larry Ogrodnek: So this is an example of a Maps thing using leaflet.js,
Larry Ogrodnek: It's like a JavaScript library that uses OpenStreet map data.
Larry Ogrodnek: We're doing a Google Maps kind of style maps
Larry Ogrodnek: view with tiles and stuff like that.
Larry Ogrodnek: And so this example just kind of shows the events.
Larry Ogrodnek: Basically, there's this hooks system,
Larry Ogrodnek: is what they call it on the Phoenix Live View side,
Larry Ogrodnek: and call it the same thing.
Larry Ogrodnek: But basically, it's a way to kind of--
Larry Ogrodnek: we saw things like PHX key click blah, blah, blah,
Larry Ogrodnek: is kind of built-in event system.
Larry Ogrodnek: So running JavaScript hooks is a way
Larry Ogrodnek: to kind of let you integrate custom JavaScript
Larry Ogrodnek: and have access to that same event system.
Larry Ogrodnek: So for this, there is a JavaScript component,
Larry Ogrodnek: which is kind of like a wrapper over--
Larry Ogrodnek: not really a wrapper, but a wrapper over some JavaScript
Larry Ogrodnek: stuff that handles this.
Larry Ogrodnek: And so we have events going two ways.
Larry Ogrodnek: And so when you click on one of the things in the sidebar,
Larry Ogrodnek: it sends something to the back end saying,
Larry Ogrodnek: oh, update your state to say you have this national park
Larry Ogrodnek: selected.
Larry Ogrodnek: And then the back end also sends a--
Larry Ogrodnek: I'm getting mixed up with this.
Larry Ogrodnek: I think when you click on the marker,
Larry Ogrodnek: that's where the JavaScript sends the event to the back end.
Michael Kennedy: MARK MIRCHANDANI: Yeah, yeah.
Michael Kennedy: Literally, this is cool.
Michael Kennedy: If I click-- so let me describe it for people.
Michael Kennedy: So we've got on one side a map of the United States,
Michael Kennedy: and on the left a nice list of the different national parks,
Michael Kennedy: the famous ones.
Michael Kennedy: If I go entirely into this JavaScript thing
Michael Kennedy: and I click on something in the map, one
Michael Kennedy: of the points of interest, which is one of these parks,
Michael Kennedy: It communicates back to PyView and is selecting it in the list, right?
Michael Kennedy: The Python bit.
Michael Kennedy: But then again, if I click in the Python bit, like Glacier National Park or one near me, the Olympic National Park, right?
Michael Kennedy: Then it will then drive the JavaScript.
Michael Kennedy: So this is the bi-directional thing you're talking about.
Michael Kennedy: This is very cool.
Larry Ogrodnek: Right, exactly.
Larry Ogrodnek: Yeah.
Larry Ogrodnek: So the JavaScript part has access to a similar component system where it's just like, oh, if I get this event, I think I call it highlight park.
Larry Ogrodnek: Then I know that, oh, I need to turn this marker on.
Larry Ogrodnek: And going the other way, the JavaScript
Larry Ogrodnek: has its own handling, like, oh, when this happens,
Larry Ogrodnek: then I should call this method on the LiveView.
Larry Ogrodnek: And so your LiveView side, like your Python side,
Larry Ogrodnek: stays the same where it's still doing event handling
Larry Ogrodnek: and also sending events if needed to the front end.
Larry Ogrodnek: But you can get access to--
Larry Ogrodnek: so maps, drag and drop stuff is a big one,
Larry Ogrodnek: even really rich editors.
Larry Ogrodnek: I've done something with using CodeMirror,
Larry Ogrodnek: which is a really nice IDE kind of editing experience
Larry Ogrodnek: in the browser.
Larry Ogrodnek: And so you can still--
Larry Ogrodnek: I think the thing with PyView, right, is it's not--
Larry Ogrodnek: I don't know, for me anyway, it's not
Larry Ogrodnek: about technology-focused.
Larry Ogrodnek: I only want to use Python.
Larry Ogrodnek: It's like, I want to have great web experiences,
Larry Ogrodnek: whatever that takes, but in a simple way
Larry Ogrodnek: that I can understand and debug and test.
Larry Ogrodnek: So yeah.
Michael Kennedy: JOHN MUELLER: Yeah, this is a very impressive--
Michael Kennedy: that's an app.
Michael Kennedy: Yeah.
Michael Kennedy: I mean, I look at it, it's like, wow, that would be kind of a big
Michael Kennedy: project to build and my feeling is it wasn't that big of a deal with pi. No it's very yeah that's
Larry Ogrodnek: kind of part of the fun thing with like making these little examples is like super fun and also
Larry Ogrodnek: like pretty easy yeah so similar one there's like that combat and board one just to quickly talk
Larry Ogrodnek: it just is a similar thing with drag and drop but the same kind of concept. I want to throw out maybe
Michael Kennedy: like just thinking back to that map one real quick before we move on it feels like this would actually
Michael Kennedy: be quite relevant for data scientists as well right like I don't think you build it as data science
Michael Kennedy: But there's a lot of like, oh, we need to build a dashboard that updates based on whatever.
Michael Kennedy: And we need these different visualizations.
Michael Kennedy: And with the JavaScript integration, I feel like you probably could do some pretty cool stuff.
Larry Ogrodnek: Yeah, no, for sure.
Larry Ogrodnek: Yeah, for sure.
Larry Ogrodnek: And I've done, and I think there are a lot of really great JavaScript, like graphing libraries.
Larry Ogrodnek: Like one that I've used before is something that I learned about just from figuring out that it's what like Google Notebook, like Google Collab, you know, their like Jupyter Notebooks thing uses called Altair.
Larry Ogrodnek: And that's something which is cool because there's basically a Python backend for generating the graph data, but then the front end is this JavaScript thing.
Larry Ogrodnek: And so I don't think I should put an example of that, but I've used it at work where we just have a very simple graph hook that wraps the Altair library and the backend generates the graph in Python code.
Larry Ogrodnek: And it's just super easy to display and things like that.
Larry Ogrodnek: And to your point, Michael, one of the really cool things
Larry Ogrodnek: with PyView is because everything is over WebSockets,
Larry Ogrodnek: any server push stuff, like if data comes in or data changes,
Larry Ogrodnek: it's really no work to get to tell the browser
Larry Ogrodnek: to update to the new state.
Larry Ogrodnek: It's super, super easy to do, which is cool.
Larry Ogrodnek: MICHAEL WOLFF: That's awesome.
Larry Ogrodnek: MICHAEL WOLFF: Yeah, so the one other thing
Larry Ogrodnek: I wanted to touch on quickly is just
Larry Ogrodnek: because I think the first example we looked at the volume
Larry Ogrodnek: was using the older events.
Larry Ogrodnek: So if you look at maybe the basic counter t-string version,
Larry Ogrodnek: like the source for that, I mean,
Larry Ogrodnek: It's the same kind of counter example.
Larry Ogrodnek: But the source is like, I think there's
Larry Ogrodnek: a count tstring5 probably to click on.
Larry Ogrodnek: And then it's the third one in the list there.
Larry Ogrodnek: But so this is just to talk a little bit about--
Larry Ogrodnek: again, it's kind of a work in progress.
Larry Ogrodnek: But the first version of the events
Larry Ogrodnek: was kind of like, oh, there's a handle event method
Larry Ogrodnek: that all events go to.
Larry Ogrodnek: But that kind of gets to be a little bit of a drag.
Larry Ogrodnek: And so we added this @EventDecorator.
Larry Ogrodnek: And so you can kind of--
Larry Ogrodnek: instead of having handle event, oh, was the method increment?
Larry Ogrodnek: Was it decrement?
Larry Ogrodnek: You can just say @Event, decrement, @Event,
Larry Ogrodnek: increment and have those separate functions.
Larry Ogrodnek: And then this is also showing the kind of T string templating
Larry Ogrodnek: where you use two strings to generate it.
Larry Ogrodnek: And the cool thing with this too is on line 58,
Larry Ogrodnek: you can see basically we're calling self.button,
Larry Ogrodnek: which is a T string template, and then we're
Larry Ogrodnek: passing in self.decrement, which is the method.
Larry Ogrodnek: And so you can kind of--
Larry Ogrodnek: I mean, it's basically just doing that binding for you
Michael Kennedy: automatically where it ends up--
Michael Kennedy: - Okay, hold on, hold on, hold on.
Michael Kennedy: So people, you have a T string,
Michael Kennedy: which is kind of Jinja-like,
Michael Kennedy: and in here you have a format statement,
Michael Kennedy: and one of the values you're putting in here
Michael Kennedy: is literally the function that has the decorator
Michael Kennedy: that is an event,
Michael Kennedy: and then that gets called back through all the magic.
Larry Ogrodnek: - Yeah, and it's like,
Larry Ogrodnek: it's like, I think it's cool that it looks like magic,
Larry Ogrodnek: but it's, I mean, it's really not magic.
Larry Ogrodnek: I mean, the thing,
Larry Ogrodnek: the simplest possible thing where basically it's just it's saving you from um like if you look at
Larry Ogrodnek: that that button method um the button template it's saying like button phx click click equals
Michael Kennedy: okay so you've created a wrapper function that then basically writes the component
Michael Kennedy: yeah that that'll wire up all exactly yeah that's pretty cool yeah but this is something i'm i think
Larry Ogrodnek: i'm really excited about because it's like um you know like one of the things that you really want
Larry Ogrodnek: want to have, like after you've been making a complex app,
Larry Ogrodnek: is a way to have components.
Larry Ogrodnek: And that was kind of challenging in the templating system
Larry Ogrodnek: that I originally started using, not just to have components
Larry Ogrodnek: because you can have includes and stuff like that,
Larry Ogrodnek: but to fit into the Phoenix Live View component system.
Larry Ogrodnek: But I think t-strings are exciting for me
Larry Ogrodnek: because it makes things like this really powerful.
Larry Ogrodnek: And you think about just even things
Larry Ogrodnek: like having really smart forms and form binding.
Larry Ogrodnek: And I have some of that, but it's a little clunky.
Larry Ogrodnek: And I think being able to have like really nice,
Larry Ogrodnek: reasonable components that leverage t-strings,
Larry Ogrodnek: make it so you have something that kind of looks very magically,
Larry Ogrodnek: but it's, you know, it's basically just, you know, templating.
Larry Ogrodnek: So, but I'm excited about it.
Larry Ogrodnek: I think it'll make a lot of things easier
Larry Ogrodnek: and easier to kind of share, you know, components.
Michael Kennedy: I love it.
Michael Kennedy: I really like the programming here, the API.
Michael Kennedy: We've got a little bit, not a lot, a little bit of time left here.
Michael Kennedy: So let's just, let's touch on actually just a couple of things.
Michael Kennedy: I think one of the issues that, you know,
Michael Kennedy: I talked about some of the magic, like some of these frameworks,
Michael Kennedy: like hide away all the things.
Michael Kennedy: Another one where there's these front end, back end,
Michael Kennedy: connected all Python, they feel like sometimes you're like,
Michael Kennedy: OK, and the way that works is you run it on our cloud system.
Michael Kennedy: You know what I mean?
Michael Kennedy: Or you run it on our special bit of infrastructure.
Michael Kennedy: And then thoughts immediately go to like, well, how durable?
Michael Kennedy: How proven is that?
Michael Kennedy: Like, could we use Kubernetes?
Michael Kennedy: Could we do it there?
Michael Kennedy: Like, gosh, I don't even know.
Michael Kennedy: So let's talk about some of the internals.
Michael Kennedy: And at its heart, this is Starlet, right,
Michael Kennedy: which is the same as FastAPI in a sense
Michael Kennedy: in terms of how it runs, right?
Larry Ogrodnek: JOHN MUELLER: Exactly.
Larry Ogrodnek: Yeah, Starlette is doing all the heavy lifting.
Larry Ogrodnek: And it handles the WebSockets and everything for you, right?
Larry Ogrodnek: JOHN MUELLER: Yeah, the WebSockets, the HTTP,
Larry Ogrodnek: the routing, even middleware, also the authentication,
Larry Ogrodnek: like using it for the authentication.
Larry Ogrodnek: Like I had to do a little bit of work to kind of make that available at the, you know, the web socket level in terms of like, because it handles like all the routing.
Larry Ogrodnek: But just the way live view works is there's really one web socket connection that's getting managed.
Larry Ogrodnek: And then internally there's routing that's done by the framework.
Larry Ogrodnek: I see.
Michael Kennedy: Because you never set that up, right?
Michael Kennedy: You don't manage different sockets in like different.
Michael Kennedy: Exactly.
Michael Kennedy: You're just like, I just want to handle event.
Larry Ogrodnek: Exactly.
Larry Ogrodnek: Yeah.
Larry Ogrodnek: But yeah, but another cover is we're using their auth system and framework.
Larry Ogrodnek: And so if you have used that or familiar with it, it's exactly the same.
Larry Ogrodnek: It's just that we make it also available at the LiveView specific layer.
Larry Ogrodnek: But yeah, so anywhere you can run Starlet.
Larry Ogrodnek: And I've been mostly using it.
Larry Ogrodnek: So that examples website that we're looking at, that is itself a PyView app that is using just Uvacorn,
Larry Ogrodnek: deploy as a Docker container.
Larry Ogrodnek: And that's primarily how I've been using it for apps
Larry Ogrodnek: that I've been writing or at work is like, yeah,
Larry Ogrodnek: it's just a Docker app with Uvocorn.
Larry Ogrodnek: But presumably, yeah, any HGI thing you could use.
Larry Ogrodnek: So yeah, there's no magic there.
Larry Ogrodnek: Yeah, anywhere you want to run it.
Larry Ogrodnek: The one thing is-- this is something that's
Larry Ogrodnek: kind of more of a future thing, but part of--
Larry Ogrodnek: that you don't have to use for a lot of apps,
Larry Ogrodnek: but some of the stuff like presence, like PubSub stuff
Larry Ogrodnek: have built in, just because it's kind of something you want to have when you have this kind of
Larry Ogrodnek: framework, but you can do stuff very easily. I have an example of this, but like, oh, this user
Larry Ogrodnek: joined this page, this user left the page, and doing things like that. I don't have a way right
Larry Ogrodnek: now for that to be multi-machine. It's really just single machine pub supplementation. And so
Larry Ogrodnek: something I'm kind of working on for the future. But yeah, there's no special requirements. Anywhere
Larry Ogrodnek: you're running a Starlette app or Fest API app or whatever should be totally fine. You do want to
Larry Ogrodnek: have sticky sessions set up because it does require you
Larry Ogrodnek: going to the same machine because we have this persistent state
Larry Ogrodnek: for the user.
Michael Kennedy: MARK MANDEL: Yeah, that is tricky with WebSockets.
Michael Kennedy: I've been dealing with that for a project I'm working on.
Michael Kennedy: And it's challenging because the natural inclination
Michael Kennedy: and a lot of the recommendation is, oh, how many workers
Michael Kennedy: do you want your uveacorn or your granion to run?
Michael Kennedy: MARK MANDEL: Yeah.
Michael Kennedy: MARK MANDEL: And oh, if you need to scale up,
Michael Kennedy: you just put it behind a load balancer.
Larry Ogrodnek: MARK MANDEL: Yeah, I agree with you.
Larry Ogrodnek: It is challenging, but I think it's a solvable challenge.
Larry Ogrodnek: And I think also it depends on kind of the app that you want.
Larry Ogrodnek: Like for some use cases, I mean, you know, the sticky part you kind of need right now anyway.
Larry Ogrodnek: But for some use cases, maybe you don't care about the PubSub or the presence,
Larry Ogrodnek: or maybe you have a way to deal with that already.
Larry Ogrodnek: Right.
Michael Kennedy: If you don't care about PubSub or presence, then as long as it just sticks to.
Larry Ogrodnek: As long as it just sticks.
Larry Ogrodnek: And even the stickiness, I feel like there's potential solutions there, right?
Larry Ogrodnek: Because like with the model, it really is like, you know, like we saw in examples,
Larry Ogrodnek: like you get past this context to operate on,
Larry Ogrodnek: you make changes to it,
Larry Ogrodnek: and you don't really care like where that came from
Larry Ogrodnek: or where it's running.
Larry Ogrodnek: And so theoretically, I think it feels like
Larry Ogrodnek: there could be a situation where that is somehow distributed
Larry Ogrodnek: or there's some kind of shared storage or, you know,
Larry Ogrodnek: it doesn't seem like impossible.
Larry Ogrodnek: I don't know that it'd be worth the complexity
Larry Ogrodnek: for a lot of use cases,
Larry Ogrodnek: but I feel like there's sort of a challenge.
Larry Ogrodnek: And the PubSub stuff, I think is something that, you know,
Larry Ogrodnek: I plan to kind of address.
Larry Ogrodnek: So I think, again, it's like,
Larry Ogrodnek: if you're okay with running Redis,
Larry Ogrodnek: that's a very solvable problem too having like multi-machine pub sub um right right right redis
Michael Kennedy: or valky have like this web socket broker thing kind of which we manage uh basically i imagine
Michael Kennedy: like your web socket connection talks to your server which then like puts you in the session
Michael Kennedy: of of a redis or valky one but then that thing actually does the pub sub across yeah and that
Larry Ogrodnek: could be that could be interesting for like i mean like one of the early things i was thinking is
Larry Ogrodnek: like oh could i could deploy this with like abys lambda you know which like seems kind of impossible
Larry Ogrodnek: And they do have, with their API gateway,
Larry Ogrodnek: they have a WebSocket broker.
Larry Ogrodnek: They manage WebSocket connections.
Larry Ogrodnek: And you just kind of get events like,
Larry Ogrodnek: oh, this WebSocket client 125 joined, whatever.
Larry Ogrodnek: And then you kind of manage that.
Larry Ogrodnek: And it kind of would be cool, just, I don't know,
Larry Ogrodnek: if a proof of concept or just if you really wanted to host on Lambda
Larry Ogrodnek: or something like that.
Larry Ogrodnek: But it's not.
Larry Ogrodnek: I don't know that I'll get to that anytime soon.
Larry Ogrodnek: Yeah.
Michael Kennedy: Well, certainly an interesting project with the way it is.
Michael Kennedy: Could certainly go farther.
Michael Kennedy: A lot of the frameworks that are good at this scale out,
Michael Kennedy: they don't have any presence or collaboration.
Michael Kennedy: It's fine, right?
Larry Ogrodnek: Yeah.
Michael Kennedy: No, it's a good problem to have.
Larry Ogrodnek: But yeah, it's something we'll figure out at some point.
Larry Ogrodnek: But I think there's still a lot of co-ops you can write without it.
Michael Kennedy: So it hasn't been a huge priority.
Michael Kennedy: No, it's very, very neat.
Michael Kennedy: All right.
Michael Kennedy: So I got two quick questions for you here.
Michael Kennedy: One, you mentioned LLMs at the beginning.
Michael Kennedy: How do LLMs do with writing PyView?
Michael Kennedy: and do you have tips for making it more knowledgeable?
Michael Kennedy: Are there, do you have like some sort of specification file
Michael Kennedy: you can give to, you know, Claude or something and say,
Michael Kennedy: I know you might not be familiar with this,
Michael Kennedy: but here's what it is.
Michael Kennedy: Now I'm going to ask you questions to work with it.
Larry Ogrodnek: That's a really good push.
Larry Ogrodnek: I feel like I should do something like that.
Larry Ogrodnek: So I have used LMS to like write, you know,
Larry Ogrodnek: like application code, not, you know,
Larry Ogrodnek: like application code, like using PyView framework
Larry Ogrodnek: like you're describing at work a lot.
Larry Ogrodnek: And it's been mostly successful.
Larry Ogrodnek: I think one of the things is it helps
Larry Ogrodnek: that the templating language--
Larry Ogrodnek: we're not using 3.14 at work yet for these projects.
Larry Ogrodnek: And so we're using the older style templates.
Larry Ogrodnek: It helps that that language is very, very similar to Jinja 2.
Larry Ogrodnek: And so that's been great.
Larry Ogrodnek: It does get confused sometimes where, obviously,
Larry Ogrodnek: we don't have the same set of built-in filters.
Larry Ogrodnek: And so I might try to use a filter that's only in Jinja 2
Larry Ogrodnek: that we don't have or that includes syntax
Larry Ogrodnek: is slightly different.
Larry Ogrodnek: So those that gets tripped up on.
Larry Ogrodnek: I think I've had a lot of success
Larry Ogrodnek: with just really simple prompts like this is PyView.
Larry Ogrodnek: It's Phoenix LiveView, but in Python.
Larry Ogrodnek: And that's gotten a lot of mileage,
Larry Ogrodnek: just even something basic like that.
Michael Kennedy: It sounds like you could create a Claude skill
Michael Kennedy: or an agent or just a set of really structured rules files
Michael Kennedy: and maybe put it on the docs and say, here, grab it.
Michael Kennedy: And throw this in.
Larry Ogrodnek: I for sure should do that.
Larry Ogrodnek: Yeah, I don't think that'd be helpful for me too.
Larry Ogrodnek: I think that's something that I kind of,
Larry Ogrodnek: yeah, just even personally want to get better at
Larry Ogrodnek: is like, yeah, I've been using these tools
Larry Ogrodnek: a lot for development and they've been great,
Larry Ogrodnek: but I've been somewhat, you know,
Larry Ogrodnek: lazy in terms of like improving my workflow.
Larry Ogrodnek: And I do see how it's like very successful
Larry Ogrodnek: when people kind of structure these things
Larry Ogrodnek: a little better in terms of like
Larry Ogrodnek: having custom commands or yeah,
Larry Ogrodnek: like agents that know about specific things.
Larry Ogrodnek: It does seem like-
Michael Kennedy: Yeah, but I do think that your cookie cutter helps.
Michael Kennedy: Right.
Michael Kennedy: Because it says, okay, here's the structure.
Michael Kennedy: Here's a little working bit of it.
Michael Kennedy: now keep building on that.
Michael Kennedy: That goes a long ways.
Michael Kennedy: So--
Larry Ogrodnek: - No, for sure.
Larry Ogrodnek: And I think even like having things like the just file
Larry Ogrodnek: seemed to help in terms of like,
Larry Ogrodnek: it doesn't, you know, it knows like,
Larry Ogrodnek: oh, to run tests, I run just tests.
Larry Ogrodnek: To run type check, I run just type check.
Larry Ogrodnek: Like it kind of knows a lot of this stuff.
Larry Ogrodnek: Doesn't have to guess about it,
Larry Ogrodnek: but it kind of would be useful.
Larry Ogrodnek: I do find it like, it's funny.
Larry Ogrodnek: It seems like the LLM get confused a lot about like,
Larry Ogrodnek: oh, do I need to run poetry run versus just Python?
Larry Ogrodnek: And it seems to always forget like
Larry Ogrodnek: how your project is set up, you know?
Michael Kennedy: Yeah, I know.
Michael Kennedy: You got to keep reminding it.
Michael Kennedy: All right, so that was question one.
Michael Kennedy: Question two, final question.
Michael Kennedy: What's the roadmap?
Michael Kennedy: You open to contributors.
Michael Kennedy: Where are we?
Larry Ogrodnek: Yeah, so like you mentioned, it's very early days.
Larry Ogrodnek: And I've tried to not be conservative about breaking
Larry Ogrodnek: changes, but I think as we start getting closer to 1.0--
Larry Ogrodnek: I think I'm at 0.8.0--
Larry Ogrodnek: there probably will be some breaking changes,
Larry Ogrodnek: because as we've already seen in some of the examples,
Larry Ogrodnek: I've gone through multiple iterations of how
Larry Ogrodnek: do I make this easier?
Larry Ogrodnek: how do I make this easier?
Larry Ogrodnek: And that's been a big focus for me
Larry Ogrodnek: is making it really developer-friendly and simple.
Larry Ogrodnek: And so I think I'll try and make some stuff
Larry Ogrodnek: a little more cohesive.
Larry Ogrodnek: So there may be some breaking changes.
Larry Ogrodnek: But yeah, I mean, you know,
Larry Ogrodnek: I want it to be super easy to get up and running.
Larry Ogrodnek: And I feel like there's work to do there.
Larry Ogrodnek: I think, you know, the short-term roadmap is,
Larry Ogrodnek: again, I want to keep working on documentation,
Larry Ogrodnek: updates, examples.
Larry Ogrodnek: I saw a really great, you know,
Larry Ogrodnek: YouTube talk recently called like Verbs, Not Nouns
Larry Ogrodnek: about Brian McDonald about like
Larry Ogrodnek: how to make your documentation more kind of like task-based.
Larry Ogrodnek: Like what is the person trying to do
Larry Ogrodnek: versus explaining technology.
Larry Ogrodnek: So I want to do that.
Larry Ogrodnek: Like I said, I think the T-string templating
Larry Ogrodnek: is very exciting in terms of making that better,
Larry Ogrodnek: figuring out the CSS story around that.
Larry Ogrodnek: That's one thing that's annoying
Larry Ogrodnek: is writing CSS in t-strings
Larry Ogrodnek: because you have to double escape all the curly braces.
Larry Ogrodnek: Better form support.
Larry Ogrodnek: I have some initial form support
Larry Ogrodnek: that kind of uses Pydantic.
Larry Ogrodnek: But I kind of want to make that a little better.
Larry Ogrodnek: And I've had situations where we have
Larry Ogrodnek: like very complex, like nested forms.
Larry Ogrodnek: And I would love to get to a point where it's just like,
Larry Ogrodnek: yeah, you just throw, here's my pandemic data model,
Larry Ogrodnek: make a form with error handling
Larry Ogrodnek: and all this stuff and validation.
Larry Ogrodnek: And I kind of want to get there.
Larry Ogrodnek: And then I think again, like larger examples,
Larry Ogrodnek: like I think you called out the Phoenix Live View,
Larry Ogrodnek: like PyBeats example,
Larry Ogrodnek: like they have this very big music player.
Larry Ogrodnek: And I have some things like that
Larry Ogrodnek: where I have like an AI chat example
Larry Ogrodnek: that are slightly larger,
Larry Ogrodnek: but kind of going to some more examples
Larry Ogrodnek: to kind of inspire people,
Larry Ogrodnek: like what can actually be done.
Michael Kennedy: Could you fully implement the live beats thing in PyView?
Larry Ogrodnek: Yes, I can.
Larry Ogrodnek: And I was thinking about doing it.
Larry Ogrodnek: I think it's interesting, the history there, I mean, I don't know.
Larry Ogrodnek: But my intuition is that part of it was that as they were building certain technologies,
Larry Ogrodnek: they wanted to show them off and have a good test bed.
Larry Ogrodnek: And so the way that it works is based on file uploads.
Larry Ogrodnek: You upload MP3s that you want to play.
Larry Ogrodnek: And I feel like that's because they wanted to show off the file upload stuff, which was
Larry Ogrodnek: new at the time, I think.
Larry Ogrodnek: And I could do that.
Larry Ogrodnek: support. In fact, I have like even multi-part S3, like very advanced file upload support.
Larry Ogrodnek: But I was thinking about doing it, but just doing streaming. I found a streaming service that is
Larry Ogrodnek: for like royalty-free music if you're using it in a non-commercial way. And I think that might be
Larry Ogrodnek: more exciting to show off like present stuff and even some JavaScript integration stuff and like
Larry Ogrodnek: synchronizing stuff. And I think also I have a simple AI chat thing, but I think maybe
Larry Ogrodnek: beefing up a little bit would be kind of cool too, because I know people are into AI stuff.
Larry Ogrodnek: But you mentioned contributions, and I think, yeah, for sure, I think the thing that, to be honest, would be the most helpful is to have people try it, try writing a simple app or a complex app, whatever.
Larry Ogrodnek: And I really want to hear what works well, what's rough, what's confusing, what could be better, any feedback.
Michael Kennedy: Yeah, more than people contributing features is people just using it to make sure it works and giving feedback on how it should be, right?
Larry Ogrodnek: Yeah, no, and contribution features are good, too.
Larry Ogrodnek: I mean, I recently set up, like, also just a call, like, on GitHub, the repo.
Larry Ogrodnek: There's also, like, a discussions thing.
Larry Ogrodnek: It doesn't have a lot of things or anything.
Larry Ogrodnek: I mean, there's two topics right now.
Larry Ogrodnek: But, you know, because I do want to get more feedback and encourage feedback.
Larry Ogrodnek: And, like, I think that's a great place to put features suggestions.
Larry Ogrodnek: But, yeah, I mean, contributions are also welcome.
Larry Ogrodnek: But, yeah, I just can't underscore enough how much, like, I want to have feedback.
Larry Ogrodnek: Because, again, I want it to be, like, I mean, I want it to be a really great app that people feel is fun to use.
Larry Ogrodnek: And they like using it.
Larry Ogrodnek: And it's easy to get started.
Larry Ogrodnek: And I know that it's not there yet,
Larry Ogrodnek: but any help to getting there would be great.
Michael Kennedy: Yeah, very cool.
Michael Kennedy: Larry, thanks for being on the show.
Michael Kennedy: Very cool project.
Michael Kennedy: I think people should certainly at least give it a look
Michael Kennedy: to see maybe it'll help them go get their app up
Michael Kennedy: and running a nice little interactive app
Michael Kennedy: way quicker than maybe they thought they could.
Larry Ogrodnek: Yeah, thanks so much, Michael.
Larry Ogrodnek: Yeah, I really appreciate the chance to come on
Larry Ogrodnek: and talk to you about this.
Larry Ogrodnek: It's been a lot of fun.
Larry Ogrodnek: I can't believe how much we talked about
Larry Ogrodnek: and how much more we could talk about.
Larry Ogrodnek: So it was really fun.
Michael Kennedy: We've got a browser full of tabs of things we didn't even get to.
Michael Kennedy: So yeah, sorry.
Michael Kennedy: Now that's how it goes.
Michael Kennedy: All right.
Michael Kennedy: Thanks for being here.
Michael Kennedy: Catch you later.
Michael Kennedy: Bye everyone.
Michael Kennedy: Bye.
Michael Kennedy: This has been another episode of Talk Python To Me.
Michael Kennedy: Thank you to our sponsors.
Michael Kennedy: Be sure to check out what they're offering.
Michael Kennedy: It really helps support the show.
Michael Kennedy: If you or your team needs to learn Python,
Michael Kennedy: we have over 270 hours of beginner and advanced courses on topics ranging from
Michael Kennedy: complete beginners to async code, Flask, Django, HTMX, and even LLMs.
Michael Kennedy: Best of all, there's no subscription in sight.
Michael Kennedy: Browse the catalog at talkpython.fm.
Michael Kennedy: And if you're not already subscribed to the show
Michael Kennedy: on your favorite podcast player,
Michael Kennedy: what are you waiting for?
Michael Kennedy: Just search for Python in your podcast player.
Michael Kennedy: We should be right at the top.
Michael Kennedy: If you enjoyed that geeky rap song,
Michael Kennedy: you can download the full track.
Michael Kennedy: The link is actually in your podcast blur show notes.
Michael Kennedy: This is your host, Michael Kennedy.
Michael Kennedy: Thank you so much for listening.
Michael Kennedy: I really appreciate it.
Michael Kennedy: I'll see you next time.
I thought of me, and we ready to roll, upgrading the code, no fear of getting whole, we tapped
into that modern vibe, overcame each storm, talk Python and me, I-sync is the norm.
you