Latest / Talk Python To Me / #483: Reflex Framework: Frontend, Backend, Pure Python
Transcript
- 0:00Let's say you want to create a web app and you know Python really well. Your first thought might
- 0:03be Flask or Django or even FastAPI. All good choices, but there's a lot to get a full web
- 0:09app into production. The framework we'll talk about today, Reflex, allows you to write just
- 0:14Python code and it turns it into a full web app running FastAPI, Next.js, React, and more,
- 0:19plus it handles the deployment for you. It's a cool idea. Let's talk to Elvis Kahoro and
- 0:25Nikhil Rao from Reflex.dev. This is Talk Python To Me, episode 483, recorded October 24th, 2024.
- 0:33Are you ready for your host, please? You're listening to Michael Kennedy on Talk Python To Me.
- 0:39Live from Portland, Oregon, and this segment was made with Python.
- 0:43Welcome to Talk Python To Me, a weekly podcast on Python. This is your host, Michael Kennedy.
- 0:51Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using @talkpython,
- 0:56both accounts over at fosstodon.org, and keep up with the show and listen to over nine years of
- 1:02episodes at talkpython.fm. If you want to be part of our live episodes, you can find the live streams
- 1:08over on YouTube. Subscribe to our YouTube channel over at talkpython.fm/youtube and get notified
- 1:14about upcoming shows. This episode is sponsored by Posit Connect from the makers of Shiny. Publish,
- 1:20share, and deploy all of your data projects that you're creating using Python. Streamlit, Dash,
- 1:25Shiny, Bokeh, FastAPI, Flask, Quarto, Reports, Dashboards, and APIs. Posit Connect supports all of
- 1:33them. Try Posit Connect for free by going to talkpython.fm/Posit, P-O-S-I-T.
- 1:38And this episode is brought to you by Bluehost. Do you need a website fast? Get Bluehost. Their AI
- 1:45builds your WordPress site in minutes, and their built-in tools optimize your growth. Don't wait.
- 1:50Visit talkpython.fm/bluehost to get started. Nikhil, Elvis, welcome to Talk Python.
- 1:57Hey, it's great to be here.
- 1:58Yeah, it's awesome to have you here. You're building some cool products, and Nikhil, you're back on the
- 2:04show. We spoke to you back in Salt Lake City at Startup Row, and now your startup is more started,
- 2:13and I'm really excited to hear about it, and that's what we're mostly going to focus on this episode,
- 2:18talking about building Python web apps. You know, normally when you say something like that,
- 2:22a person who is not a web developer would go, oh, you're building apps with Python, web apps with
- 2:28Python. That's cool. A web developer would be like, okay, what is that? That's Python, CSS,
- 2:32HTML, JavaScript, React, et cetera, SQL. There's a lot going on normally, but we can winnow it down
- 2:40a little bit and have a little more focus. When we say Python web apps, it's a little more like that,
- 2:45right?
- 2:45Yeah, definitely. And I think a lot of people, when they hear Python web apps, they think of,
- 2:50you know, Django, Flask. Like these are, they call themselves Python web frameworks,
- 2:53and they're really great frameworks. But like you mentioned, there's a lot of things that go into
- 2:57web development. There's front-end, back-end, hosting, et cetera. And when you think of frameworks
- 3:01like Django, Flask, they do a great job of handling the back-end, the database, the kind of connection
- 3:06layer. But like you mentioned, when you have to write the front-end, you end up having to kind of go back
- 3:11to HTML, React, JavaScript, and the traditional tools. And generally in web development, you'll set
- 3:16up your back-end as kind of one service, your front-end as one service, hook them up through some sort of
- 3:21API and develop through that. And it works great, but one part, like you mentioned, is there's a lack of
- 3:27unification. So when it comes to building an app, you have to piece together a front-end, a back-end,
- 3:31then figure out how to host it. So a really big part of why we started Reflex was to kind of simplify
- 3:37all these different layers of web development into one batteries-included framework. And one of like
- 3:43the biggest challenges along with the batteries included is having everything built in, but also
- 3:47keeping it flexible enough, right? Because people want to do all sorts of stuff with their web apps.
- 3:52So that's really one of the main challenges that we faced going through all this was how
- 3:56can we make a framework that, you know, people can just get started, but it doesn't box them
- 4:00in. They can still make all the stuff they were going to make, you know, using their JavaScript
- 4:03apps.
- 4:03Right. That is the big challenge. And we're going to dive into that. You guys got some awesome
- 4:07stuff. But before we do, maybe, you know, it's been two years or so since you've been on
- 4:10the show. Give a quick introduction, just who you are.
- 4:13Yeah, definitely. So yeah, I'm Nikhil. I'm co-founder here at Reflex. Last time we chatted was about
- 4:18a year and a half ago. At that time, our company name was Pinecone with a Y. That was at Startup
- 4:23Row. And our mission when we started, and even now, is to just simplify the whole process of
- 4:28web development from front-end, back-end, hosting, all these parts, and make a framework that simplifies
- 4:34all these parts so a newcomer can easily share their ideas without getting all caught up in
- 4:39learning new tools, learning new languages, boilerplate, and all this.
- 4:43So that's been our goal from the start. And maybe just some background on why we even came
- 4:48to this idea. So prior to working on this, I was working at a self-driving car startup, and then I
- 4:54was working at Apple. And at both these roles, I was working on AI teams with really talented engineers,
- 4:59but we were all Python engineers. So we could do, you know, anything with database, backend,
- 5:04all this stuff. But when it came to something as simple as make a UI for this app, make a dashboard
- 5:09to showcase this data, you know, make a little form to submit it. You know, there's sometimes
- 5:14these senior engineers would be like, okay, that's not my domain. I can't do that in Python. You know,
- 5:18someone else go handle this.
- 5:20I have a PhD in machine learning, but I can't build a website. So now what?
- 5:23Exactly. And that's kind of where we are. And a big reason of that is if you think about,
- 5:28you know, different languages and their use cases, Python is used in so many, it's one of the most
- 5:32broad languages. If you think about all the areas it's used, backend databases, AI, ML, all these areas,
- 5:38but there's really one place that it's not used traditionally. And that, and that's kind of
- 5:42front end development. And for there, like JavaScript is king. And if you take the inverse of that and
- 5:47think about JavaScript, it's one of the most popular languages in the world, right? Like it's,
- 5:50it's one, two or three up there. And if you think about the use case for it, it's all web,
- 5:54it's mostly all around web applications. So what we see, what we kind of notice is, you know,
- 5:59people love Python. They want to do all their work in Python when it's accessible and people love web
- 6:04development and they use JavaScript because they love web development, but there's not much usage
- 6:08of JavaScript outside that domain. So really our big focus was, well, can we fill in this gap in the
- 6:13Python ecosystem where people are doing everything in Python? And then suddenly this one domain of
- 6:18websites, front ends, that, that can't be handled and they need to, you know, use a different tool,
- 6:22use a different language, outsource that. And that was a big thing we wanted to solve. The same people
- 6:27with the ideas, building the backend, building the AI, building the, whatever it is, should be the,
- 6:31also the people presenting it, building the UI layer and kind of sharing their ideas.
- 6:35Yeah, absolutely. I, many people I talked to would rather build everything in Python, but they,
- 6:39they end up piecing it together as they have to. Elvis, good to see you.
- 6:44Yeah, same.
- 6:44Yeah. Quick introduction about you.
- 6:47Yeah. So I guess we met at PyBay.
- 6:49Yeah, we did.
- 6:50Yeah. So that was very, very fun. And yeah, so I'm Elvis, he and his, I'm working at Reflex as a
- 6:56developer advocate. And prior to this, I was working at Warp. So I was there like three years
- 7:01doing like developer experience, developer relations.
- 7:03Yeah. Shout out to Warp.dev, man. That is an awesome terminal. I really enjoy that. I use that
- 7:09pretty much universally now. And yeah, I'm, thank you for that recommendation. It's still going strong.
- 7:14Very good team. Really good product. Yeah.
- 7:17Yeah. Awesome. So now you're working at Reflex, formerly Pinecone, same company, new name.
- 7:21Yeah. Awesome. Yeah. Even doing more, you know, this Warp is more Rust, right? So now you're more
- 7:26in the Python side of things. Yeah.
- 7:28Yeah. But even there, I was like, everything that I was building was like internal tooling to like
- 7:32optimize developer experience. And so everything was in Python. And so that's how I actually came
- 7:38across Reflex. And then I was like, oh, this is a dream, like being able to like work in open source
- 7:42and build Python apps and like serve the community. And so when I saw that job posting, I was like,
- 7:49whoa, I would love to join. And they were in SF. So that was great. So I could just walk over to the
- 7:52office and things. So yeah, that is kind of the magic of San Francisco, right? Like it's not you and
- 7:57potentially a whole family move thousands of miles away. It's just you take a different bus or a
- 8:02different BART train or something. Yeah. Very cool. All right. Well, Nigel, let's talk really quickly
- 8:08just about startup lane. You know, like I was just looking back on this as I knew you were coming on the
- 8:13show and I was like, well, you know, what happened to all those companies? And I don't have a great,
- 8:18totally good sense. I know that some of these have pivoted. You know, we had Ponder, we have
- 8:24Generally Intelligent, we had Wereobots, Neptyne, Nyxtla, Pretty Base, and Pinecone, which is now Reflex.
- 8:32And this was, well, what is this startup row really quick while we're on this topic?
- 8:37Yeah. So this was back when we first started. I think our company was maybe one or two months old. And
- 8:42we were, we had just got into, we were part of the Y Combinator winner 23 batch.
- 8:46So while going through that, we launched on, I think, Hacker News early January. And that's when
- 8:52we first started, you know, publicizing our open source, getting users on it. And we got, we got
- 8:56quite good traction when we started. And part of one of the events that was happening was PyCon,
- 9:01which was, I believe in April of that year. And it was a great opportunity for us as a Python,
- 9:07you know, a Python company, like to kind of meet our audience. And yeah, so part of that was the
- 9:12startup row where there was a lot of, you know, I think seed or like very early stage startups
- 9:17coming to present. So at that time, we were maybe only two months old. So very early, but it was still
- 9:23a great, really great experience. You know, I think it was probably the first event, you know, that we've
- 9:27done as a company. So that is a really good experience to meet different Python developers and to meet all
- 9:33like the other developers that, you know, the companies you mentioned, like, even ones that
- 9:38were not, that aren't listed here, there's a bunch of awesome Python people that came there. So
- 9:41yeah, it's not just the companies that are in startup row. That's its own special thing. But the
- 9:46whole expo floor hall is a pretty awesome place to just walk and mingle and learn what people are up to.
- 9:52Yeah, definitely.
- 9:52Yeah, yeah, that's cool. I know that Ponder, Ponder got acquired. So congrats to them.
- 9:57Oh, nice.
- 9:58I got acquired by Snowflake, which is, you know, that makes a lot of sense. Yeah.
- 10:03Yeah, I know, generally intelligent, their founders are some of our friends,
- 10:07they're an investor in our company, they rebranded now to imbue. So I think they're doing well as well.
- 10:13Yeah, I think whoever put together that, that group, whoever selected the companies that go there,
- 10:17did pretty good. Because, you know, startups don't have a typically a huge likelihood of succeeding.
- 10:22But I think most of these are still around. So that's awesome.
- 10:24Yep.
- 10:24Yeah, cool. All right. Well, let's talk. We've introduced it a little bit. But reflex, let me just read,
- 10:32I'll read the little, the H1, H2 for you. And then we'll go from there as that front end,
- 10:36back end, pure Python, and then the open source framework to build and deploy web apps,
- 10:41no JavaScript required. There's a lot to unpack there. So tell people what reflexes,
- 10:46and then we'll dig into the use cases and some of the open source stuff and so on.
- 10:51So I think we kind of talked about earlier, reflexes of Python framework to build web apps in Python. And it's an open source framework. So you don't have to sign up for a SaaS or do anything. You just do pip install reflex kind of like what's shown at the bottom. And you can start using it like any other Python library. And like I mentioned, the key distinction that we're trying to do is kind of unify the whole web stack. So all the parts that normally go into web development, building a front end, building a back end, connecting them, maybe including a database, and then deploying it.
- 11:19Usually these involve using several different tools, technologies, even often multiple languages. And the overhead for that could be really high. So if you think about before, like a full fledged web app, usually you're not going to do that unless you have, you know, you have like a mission to do like you have something you're trying to make, you have it kind of specked out and you're going to kind of invest that effort into it. It's very hard, or most people aren't going to, you know, prototype a web app or kind of build out like that, because the overhead needed is way too high to kind of mess around.
- 11:49So what generally happens, especially for Python developers is they'll use Python scripts, they'll use Jupyter notebooks. And in the Python community, also, there's other pretty good frameworks, things like Streamlit, Gradio, which are also in the Python environment.
- 12:03And I think try to target a very similar problem that we're doing where, you know, people have their data, people know Python, and they want to showcase it. So these are kind of the existing tools that were there before we started. And I think they all have their place to get started with, but they're very limiting and what you can build with them, right? Like, it's good for the most basic prototype, you can have a script, you can have a Jupyter notebook.
- 12:23But this is not something necessarily you'd want to share within your team to build out to a larger app. Like usually, once it becomes a bit more complex, you hand it off to another team, or if you're brave, you go learn JavaScript or something. But usually there's a point where it's like, all right, I've done my job, like someone else, like go make this production ready. And a big part of what we're trying to do different at Reflex is compared to other Python, and I'd even say other like non JavaScript frameworks,
- 12:49is to keep everything in, you know, Python in one language, but without having any of these trade offs that usually come with a low code or no code platform. So usually low code and no code, they sac they exchange things like performance features, things like that for usability, customization, customization. So you can build a certain subset of apps. But you need to kind of, you know, keep your aspirations confined to what that framework is going to give you like you want some random component, you want a mapping component, you have to hope that framework has it.
- 13:19You want to integrate with a certain database, you have to, you know, hope that they're going to give you that integration. So one of the very nice things about Python is for especially the back end integrations, right?
- 13:28Actually, before before that, let me just back up one second. So compared to a lot of these low code, our goal was to have the same framework, you use, you can easily build a prototype your app, you know, in a few hours, build a quick prototype of your app.
- 13:40And you can use that same framework to then grow your app all the way to a production grade app. So if you're like, look at our main website, reflex.dev, this entire website was built in reflex. So you can kind of see that badge at the bottom.
- 13:51I think this is kind of distinguishing thing from others, like, usually to build a website like this, you would need to use JavaScript, but there's, this was entirely built in Python and reflex. And it just goes to show like the kind of, you know, along what we're chatting about, of, you can build, you know, a basic chat app, a little prototype app, as kind of is shown in the demo section right below on the landing page, where we have a bunch of, you know, different use cases.
- 14:13So you can build that prototype, but you can also extend that all the way to a production app that's, you know, serving either internal users, or even in, in our case, for some startups that are serving external public users using reflex.
- 14:24Yeah, a lot of times when I talk to people about these kinds of apps, often, it's, we've got an internal app, and there's 20 people using it. And it doesn't really matter if it takes a little while for the app to load up. And, you know, we're not worried about SEO or any of those things, right? But to make your, your product a landing page, and that's a pretty big deal.
- 14:44Yeah. And I'm not saying that's the typical or intended use case.
- 14:48Sure, of course.
- 14:49There's other things if you just want a static landing page, but it was more to show the extent to which it could be used. But like you mentioned, a lot of our there's kind of like two domains of people that want to use us. The main audience is really developers, engineers that are not web devs are not JavaScript devs. So obviously, that includes, you know, hardcore Python people who are, you know, senior Python developers. But a lot there, it's also just like anyone who knows a bit of coding, because Python tends to be, you know, people have taken one CS class, it tends to be a Python class, they've learned a bit of Python.
- 15:19So we actually see use cases outside of even software engineering. So people in finance, manufacturing, biology, where they, you know, before had an Excel spreadsheet, but they knew a little Python, and they're now able to develop, you know, these internal apps for their companies.
- 15:32So that's kind of the developer profile we're looking at. And in terms of the companies and use cases, it's a lot of, you know, small teams that they want to do more with the team they have, like they like for on one hand, it's kind of startups, you have a one two person startup, and you need to get your, you know, app demoed, you're building some AI thing, and you want to get a demo, you don't want to go hire a contractor or front end developer to build that you want to iterate quickly, and kind of work through that, especially during that iteration phase, right?
- 16:00Like when you want to iterate, you don't even know fully what you want to build. So it's really empowering to, or what we're trying to do is empower people by giving them a tool where they can iterate on their ideas, and not have to depend on someone else.
- 16:12This portion of Talk Python To Me is brought to you by Posit, the makers of Shiny, formerly RStudio, and especially Shiny for Python. Let me ask you a question. Are you building awesome things? Of course you are. You're a developer or data scientist. That's what we do. And you should check out Posit Connect.
- 16:30Posit Connect is a way for you to publish, share and deploy all the data products that you're building using Python. People ask me the same question all the time. Michael, I have some cool data science project or notebook that I built. How do I share it with my users, stakeholders, teammates? Do I need to learn FastAPI or Flask or maybe Vue or React.js? Hold on now. Those are cool technologies, and I'm sure you'd benefit from them. But maybe stay focused on the data project.
- 16:57Let Posit Connect handle that side of things. With Posit Connect, you can rapidly and securely deploy the things you build in Python. Streamlit, Dash, Shiny, Bokeh, FastAPI, Flask, Quarto, Ports, Dashboards, and APIs. Posit Connect supports all of them. And Posit Connect comes with all the bells and whistles to satisfy IT and other enterprise requirements. Make deployment the easiest step in your workflow with Posit Connect.
- 17:23For a limited time, you can try Posit Connect for free for three months by going to talkpython.fm/posit. That's talkpython.fm/P-O-S-I-T. The link is in your podcast player show notes. Thank you to the team at Posit for supporting Talk Python.
- 17:39Yeah, I think one of the problems with the low-code, no-code stuff for people in our orbit is they know code. They're good developers. They just might not be front-end developers or designers or whatever. So I think it's probably a little frustrating to work with really low-code, no-code type of stuff.
- 17:58Because you're like, ah, if I could just program it, just a little bit of code would totally make this work. But it's in JavaScript or it's in something else. Like, Elvis, when you're talking to people about this, you know, like, how do you present this versus something like Retool or Gradio or something like that?
- 18:13I was using Retool at the last company. And one of my frustrations was the fact that I didn't have control.
- 18:19I think they do make pretty cool stuff, but it's different, right?
- 18:22Yeah, it is different. I think Retool is very powerful. They have a lot of plug and play.
- 18:26I think for someone who's, if you're coming from a developer background, I think you're so used to having full control that, like, giving some of that control away can be a difficult adjustment.
- 18:36And I think one of the nice things about Reflex is that all of these UI components get transpiled into React, right?
- 18:43And so one of the key value props is that you're bringing an entire ecosystem closer to back-end people.
- 18:50And so, like, there's a couple of companies that will have someone doing front-end and making components just for their internal tools team.
- 18:58And it's like, you can just wrap those in Reflex. And now all of your components still adhere to, like, your style guide or to your theme.
- 19:05And so you're not really, like, limiting people in terms of, like, the components that they have available to them because it is React under the hood.
- 19:11Oh, that's pretty interesting. Yeah.
- 19:13Yeah. So it's, like, very elegant because it turns into FastAPI and React.
- 19:17So it's like, you're not really limited when it comes to, like, producing apps that can get bigger or, like, scale or have, like, routes and things.
- 19:24It's basically some developer tooling on top of React.
- 19:29And then, so what you end up programming is probably mostly generates React.
- 19:33And then it's also FastAPI on the back-end. That's really neat.
- 19:37Well, basically, going back to, as we were developing this, the most important thing we kept in mind was, okay,
- 19:42we want to make it really easy. You know, a newcomer should be able to build this.
- 19:45But not have, pretty much have ways to do anything, right?
- 19:49Like, never make people hit that graduation point where they're like, okay, I've hit the limits of Reflex.
- 19:54Let's go use a serious framework like React.
- 19:56So it's very intentional that people never hit that goal.
- 19:59And, like, one way that we achieve that is you code everything in Python, but the end output that it compiles to is a production-grade web app.
- 20:07So for the front-end, though you're coding it in Python, the front-end will compile out to a Next.js app.
- 20:11The back-end will compile out to a FastAPI back-end that hookup together.
- 20:15So it's pretty much the same architecture you would write as if you were writing it by hand.
- 20:19So there's no, there's, like, we're not taking a shortcut as in, like, if you were to write it by hand, it would actually compile.
- 20:24You would probably write a Next.js front-end, FastAPI back-end, and connect it.
- 20:28And we're kind of giving a layer on top of that.
- 20:30And by developing on top of React, it goes back to this.
- 20:33We don't want to reinvent the wheel.
- 20:35WebDev is a really mature ecosystem.
- 20:37We're not going to be able to remake React and all the components out there.
- 20:41So when we started, our big approach was let's wrap React.
- 20:44And not only, like, do our components wrap React, but we make it very easy for developers to wrap their own components.
- 20:52So kind of like what Elvis said, we have companies, like, Fortune 100 companies, that internally they have their own React, you know, component library that they must use for every app that they're building.
- 21:02And they were able to wrap those in Reflex, and now they can use, you know, their private custom React components.
- 21:08One person wrapped it once, and now any Python developer is able to access it and develop with it.
- 21:13So our really big point is, like, you're not going to be locked in.
- 21:16We have, you know, 60-plus components built in.
- 21:18But anything that's possible in React and JavaScript, you can easily bring that to Reflex without waiting for us.
- 21:22Okay, so there's a bit of an escape hatch to just go down straight to React.
- 21:26The nice part is you don't have to write the React directly.
- 21:29I mean, you can write it once.
- 21:30But after that, we have a third-party component ecosystem.
- 21:33So I can show you on our website later as well, but many people have published their own third-party components.
- 21:38Oh, interesting.
- 21:39For example, like, we don't have a map component built in.
- 21:41So last week, someone published a Reflex map component.
- 21:44So if you want to, like, hook up a map into your thing, it's now possible.
- 21:47And there's a lot of these...
- 21:48AG Grid.
- 21:48Yeah, AG Grid, you know, audio recording, and all these, like, niche cases, right, where we're not going to be able to support it all.
- 21:54But the nice part about having an open source and open source community is community can add to the project, shared with others, and everyone can benefit from it.
- 22:02Another one of the challenges of low-code, no-code type stuff has to do with the deployment side of things.
- 22:08I maybe buy a SaaS subscription at some low-code place.
- 22:13But, you know, in practice, the performance is just not good enough to, if you put it on the internet, it'll just not take it or something like that, right?
- 22:22If it's basically JavaScript over FastAPI, like, that's a very well-known and super scalable setup, right?
- 22:29Part of that is, in the unification, it wasn't only front-end, back-end, it was also deployment, which a lot of people, they build their app, and deployment takes as long, if not longer, than the actual building, especially...
- 22:39And the DevOps all along the way, yeah.
- 22:41Yeah, especially if you've never done this, right?
- 22:43Like, to go learn about, you know, how to domain names and what is, like...
- 22:46SSL.
- 22:47What is S3, SSL?
- 22:48Like, all these things take a long time.
- 22:49And that, so, and going back to the thing of balancing that thing of batteries included, yet, if you don't want to use our batteries, you know, you should be able to self-host it.
- 22:58So, along those lines, what we've included in Reflex is a one-line deploy.
- 23:02So, after you build your app, you can just type Reflex deploy.
- 23:05We set up all the infrastructure, and you'll get a URL back that anyone can access your app through.
- 23:11So, we have the ASL hosting service built in as well to Reflex.
- 23:14And if you don't want to use that, like many companies, you know, say you want to deploy on your private cloud, or et cetera,
- 23:19it's really important to us to stay with, like, open source and make it so, you know, if you want to use it in your own use case, that's always possible.
- 23:26So, we have guides and make it easy to deploy on all these.
- 23:29And like you said, because it's kind of a standard output, it's kind of easy to self-host it yourself as well.
- 23:34Right, right.
- 23:34What you know about running FastAPI probably translates pretty well.
- 23:38Yep.
- 23:38What's the database story?
- 23:40There's got to be a database, right?
- 23:41This goes back to, like, the whole batteries yet flexible.
- 23:43So, we have a built-in ORM similar to Django.
- 23:46It's nothing but a kind of light wrapper around SQLAlchemy, but kind of hooked up more to Reflex.
- 23:53So, kind of taking care of some abstractions in terms of making the models work with Reflex state, et cetera.
- 23:58So, the nice part is we have first-class support for any SQL database because of the SQLAlchemy, like, tight integration.
- 24:05When you start Reflex, you have a built-in SQLite database that gets any app that wants it.
- 24:11It's there for you.
- 24:12You don't have to do any setup.
- 24:13So, you can start developing with databases right away, like, without, you know, having to learn too much outside or doing any setup.
- 24:20And then once you want to go to, you know, production, deployment, and you want to use, say, Postgres, MySQL, or whatever you want to use for your actual database, it's just a matter of, in our config, putting the database URL that you want.
- 24:33So, we make it really easy to partner with whatever you're doing.
- 24:36So, a lot of people use us with providers like Supabase, Neon, where they set up their database using one of these providers, and they can easily connect it to their app.
- 24:43That's cool.
- 24:44So, basically, anything SQLAlchemy supports, just set the connection string, and you're good to go.
- 24:48Along that line, right?
- 24:49Like, a lot of people ask us follow-up questions like, well, how do you handle MongoDB?
- 24:53How do you handle NoSQL?
- 24:54How do you handle, like, XYZ tool that I want to use in my app?
- 24:58And this is another part where I think our big advantage over low-code, no-code frameworks, where, you know, if you want, say, a drag-and-drop builder to support your random database, because there's no code in it, you're kind of dependent on them, right?
- 25:10Yeah, yeah, yeah.
- 25:11For us, we kind of have this kind of nice privilege where we can say, hey, it's just Python.
- 25:14Go use the Python library.
- 25:15Anything you can do in Python, you can, like, integrate in Reflex.
- 25:18So, we give a lot of first-class support, but a lot of what we're doing is we're on the shoulders of React and Python.
- 25:25Oh, interesting.
- 25:26So, if I wanted to use, say, Beanie and Pydantic and MongoDB, I'd just do that?
- 25:30Just do pip install, whatever the library is, and use it like any Python.
- 25:33So, for example, like, a huge use case people use us with is, you know, AI apps.
- 25:38So, a lot of people use OpenAI, Anthropic, and all this.
- 25:40And it's just a Python library away.
- 25:42And oftentimes, they already have written that Python script first, right?
- 25:46And they just want a UI on top of it.
- 25:47So, it's, like, even easier to hook up at that point.
- 25:49Anything you want to add to that before we move on?
- 25:50This whole deployment, managing, DevOps-y side of things?
- 25:54Yeah, it definitely reminds me of the code where, like, any, like, sufficiently advanced technology is, like, indistinguishable from magic.
- 26:01Because, like, we recently sponsored CalHacks.
- 26:04And, like, being able to, like, see people who are taking, like, CS1, CS2, like, the magic, like, in their eyes.
- 26:11And, like, they can, like, run it.
- 26:13And then, like, a website comes up.
- 26:14Yeah.
- 26:15It's just so compelling, you know?
- 26:16And then, so, like, for me, I'm just, like, looking forward to the future where more people can use it.
- 26:21And then we can just, like, make, like, the web ecosystem, like, more democratized, you know?
- 26:25Like, just bringing power to people who, like, don't have a JavaScript experience, you know?
- 26:29Yeah, it's a big part of the Python story as well, right?
- 26:31One of the alternatives to this is notebooks, right?
- 26:34Which I know is not even close to the same thing.
- 26:36But a lot of people who are not web developers or just don't want to take a month to build a website, right?
- 26:41They'll kind of create a notebook and use the notebook to visually communicate in interesting ways, right?
- 26:46But when it comes down to, I want something that feels like a website for someone, it kind of falls short most of the time.
- 26:52They use a notebook for that.
- 26:54Yeah.
- 26:54So the reason I brought it up is notebooks totally democratized visualization and interaction for data scientists in a way that was massive.
- 27:02Yeah, I completely agree.
- 27:04And I think most people would agree, like, a web interface is nicer than a notebook, but a notebook is so much easier to build, right?
- 27:09So when considering that trade-off, people are like, all right, here's my Jupyter notebook.
- 27:11And what we're trying to hope, or what we're trying to do is make it as easy to, okay, convert your notebook to a website that's more easily shareable, more easily kind of deployable, and all this other stuff.
- 27:21This portion of Talk Python To Me is brought to you by Bluehost.
- 27:26Got ideas, but no idea how to build a website?
- 27:29Get Bluehost.
- 27:31With their AI design tool, you can quickly generate a high-quality, fast-loading WordPress site instantly.
- 27:37Once you've nailed the look, just hit enter, and your site goes live.
- 27:41It's really that simple.
- 27:42And it doesn't matter whether you're a hobbyist, entrepreneur, or just starting your side hustle.
- 27:46Bluehost has you covered with built-in marketing and e-commerce tools to help you grow and scale your website for the long haul.
- 27:54Since you're listening to my show, you probably know Python, but sometimes it's better to focus on what you're creating rather than a custom-built website and add another month until you launch your idea.
- 28:03When you upgrade to Bluehost cloud, you get 100% of time and 24-7 support to ensure your site stays online through heavy traffic.
- 28:12Bluehost really makes building your dream website easier than ever.
- 28:16So what's stopping you?
- 28:17You've already got the vision.
- 28:18Make it real.
- 28:19Visit talkpython.fm/bluehost right now and get started today.
- 28:24And thank you to Bluehost for supporting the show.
- 28:27Along those lines, I think we're going to chat about it maybe a bit later.
- 28:31But our goal, like right now, a big part of it is making, okay, you can write your UI in Python, right?
- 28:36So it's making that part of it more accessible.
- 28:38But our goal is not necessarily, you know, to stop at Python.
- 28:43Our goal is just to make it easy for someone with an idea to build a web app.
- 28:46So along those lines, like as we started, a lot of the positive comments people have said is, okay, now I can, you know, one language, one framework.
- 28:53But still, it's just because, you know, Python, that doesn't suddenly mean you're a designer, you're a web developer.
- 28:58Like I can now make, you know, an Airbnb style website just because the HTML is now in Python.
- 29:04So a big part of what we're trying to do is accelerate a lot of the entire process.
- 29:09Because fundamentally, I think people have in their mind, like they know what they want to build.
- 29:14They know what it looks like in their head.
- 29:16In their mind, they can visualize it.
- 29:17But it's kind of their technical implementation and their tool.
- 29:20Like all of those are not good enough for what's in their mind to become reality.
- 29:25So that's why they have to settle for notebooks, settle for, you know, an approximation of what's in their mind.
- 29:29Because they're like, okay, this is with my time and effort and tools.
- 29:32This is like what I'm trying to do.
- 29:35And along those lines, so I think Python is definitely one good aspect of it because, you know, it's now in their language.
- 29:40We're trying to bring it to where they are.
- 29:42But there's a lot of stuff that I think the whole web dev ecosystem is going to change in the upcoming years.
- 29:48And we want to be part of this kind of new age of frameworks that's incorporating things like AI along with code.
- 29:55And kind of that integration between the two where a lot of stuff, you know, that's easier to do in AI.
- 30:01It makes sense to do there.
- 30:02But it's important that the output of that is something that the developer can understand, edit, and kind of work with.
- 30:07So it's still their contribution that's getting, you know, built in the end.
- 30:11I'm skeptical of many integrations of AI into, I'll say, most apps.
- 30:16But I know you're leaning towards not playing a little bit.
- 30:20It's pretty neat.
- 30:20So, yeah, we'll get to that.
- 30:22But, yeah, it's pretty empowering because, you know, if you just stare at a blank screen of HTML where it literally just says angle bracket HTML, angle bracket body, now what?
- 30:31Like, that's daunting, you know?
- 30:33That's kind of the point we're trying to go after because there is, you've probably seen, like, there's a lot of AI website generators that, you know,
- 30:40they'll make kind of your landing page.
- 30:41I think there's two real downsides to a lot of existing ones that we're trying to kind of attack differently.
- 30:46One is they're mostly meant for static sites, right?
- 30:49Like, they'll give you your thing, but it's very hard to add your actual stuff to it.
- 30:53And part of that is they generate kind of the stuff, but it's not in a way that's usable by the end user.
- 30:59So you could generate a nice dashboard interface.
- 31:02But for a developer, they're like, well, how do I actually put my data in there?
- 31:05How do I hook it up with my database?
- 31:06How do I actually make this nice thing actually practical?
- 31:09So I think that's kind of the approach we're trying to do is, like, once, if we have these AI features, it's not just an AI to build.
- 31:16It's something that the developer can also, you know, understand the output with and work with it.
- 31:20So it's like Python we see as great in this thing as, like, an intermediate language with which both AI can kind of write to and a developer can actually understand.
- 31:29And compared to an AI outputting a bunch of React code, which would be really hard for then a Python developer to actually go make modifications with.
- 31:36It's write only.
- 31:37And you can't do much with it after it's created.
- 31:39Exactly.
- 31:40I want to talk through some of the little examples and what code looks like within the constraints of a mostly audio show to the extent that we can do that.
- 31:46But I want to talk open source first.
- 31:48Because one of the considerations you guys said, hey, let's circle back and talk about Reflex.
- 31:53I'm like, wait, I don't know what Reflex is.
- 31:55But then it's Pinecone, right?
- 31:56I'm always a little bit hesitant to have just a company on the show because I'm afraid it's just, well, we're just going to talk about our product all day.
- 32:03But, you know, I think there's one.
- 32:05I feel like having an option to write Python code across the board is super interesting for Python people.
- 32:12There's a few other things that I've covered previously that are somewhat like that.
- 32:16Like Anvil is close, but it has a very different approach.
- 32:19And Streamlit, very different approach, but kind of somewhat very slightly sort of similar output, but not the same for sure.
- 32:26But also just the fact that you guys have this also as open source.
- 32:30I think that that's a pretty compelling option.
- 32:33And so one of the things I think this makes it pretty relevant for people.
- 32:36And then I looked at the GitHub repository and it has 20,000 stars.
- 32:40That's like a third of Flask or a third of Django.
- 32:42That's pretty good, you guys.
- 32:44When we started, we always wanted to open source it from the start.
- 32:47I think that was like very, very important to us.
- 32:49I think our idea was I'd rather have a large number of users and only X percent of them,
- 32:55say on a paid product than a small number of users that are all paying.
- 32:58Like our biggest thing is all about kind of the community.
- 33:01And related to that, I don't think there's been many, especially in like, say, web frameworks.
- 33:06I can't really think of many web frameworks that are not open source that I've really took off because a big part of things like web frameworks are the ecosystem around it, right?
- 33:15Like it's not just the framework, but what are all the stuff people build on top of it?
- 33:19Like the integrations, the components, the tutorials and all this stuff around it.
- 33:24So a big part of what we wanted to do was open source it, make it really easy for people to get started and not have a huge like burden to even start.
- 33:33And yeah, pretty much lower all the activation energy that someone would need to get their first app up and running.
- 33:38Yeah. And actually the open source has really been good.
- 33:41Like it's been awesome for our community.
- 33:43So when we first started like a year and a half ago, like people, what is very surprising to me?
- 33:48Like this is the first time I've done an open source project, like, like, you know, led an open source project.
- 33:53And it's what was most surprising in a positive way was like how many people are eager to contribute to open source?
- 33:59Like I did not expect when I started, but like so many people were like, hey, can I work on this?
- 34:04Hey, can I add this feature?
- 34:05And what's really nice is like we have our reflex core stuff that we're working on, but everyone has a different use case of what they're trying to build with it.
- 34:13Right. So it's like this balance of like, okay, we have a plan of our roadmap.
- 34:16We're going to add these features.
- 34:17But then other people will say, well, I want an audio component for this and I want this.
- 34:22And the nice part about being open source is you really encourage people to add their own stuff to it.
- 34:27When they hit a bug, a lot of people are like, all right, it's open source.
- 34:30I can just go fix the bug.
- 34:31I don't have to rely on the maintainers.
- 34:32So for the and like going back to kind of the velocity, because we started around a year and a half ago, and I think we're getting pretty good traction.
- 34:40And a lot of that is because of our great kind of community that's been building a lot for us.
- 34:45Yeah, it is an interesting aspect of choosing what platform you want to work with.
- 34:49Right. Because it's closed source.
- 34:52It might be great, but you're stuck with whatever you're going to get.
- 34:54Right. Maybe fingers crossed something comes, but you know, no promises.
- 34:57Right. But if it's relatively small, like a component or something.
- 35:01Yeah. Then people can add their own.
- 35:03And that's pretty cool.
- 35:04Whenever I'm like evaluating like tools to bring into our tech stack, especially for go to market.
- 35:09One of the first things I look at is like, it's like open source and then their docs.
- 35:13And like whether they have an API.
- 35:14Like those are like my first three like top tier criteria.
- 35:17That way we're not like constrained in the future.
- 35:20If the company decides to pivot or to change their roadmap and things.
- 35:23Yeah. Pivot. It definitely could turn out bad if it's your platform.
- 35:26Right.
- 35:27So Apache 2 license.
- 35:29Tell me what, what does that mean for people who want to go and build stuff with us?
- 35:32Basically, we wanted to make it as permissive as possible.
- 35:34So I think the gist of it is you can kind of use it for anything you want paid, commercial, open source, whatever it is.
- 35:40The only restriction, as far as I understand, I'm not an expert, by the way.
- 35:44So maybe anyone looking into it, consult a license themselves.
- 35:48But I think it's just you have to like attribute trademarks if you're copying the code with it.
- 35:52But we really wanted to make it super permissive, you know, like let anyone use it and then build products on top of it.
- 35:58Like our hosting, like, you know, more premium components, like built in auth that will provide value for people that are using it in a, say, a business or more, you know, production use case.
- 36:08So the core open source, it's really important.
- 36:10Like anyone who wants to build anything, like we want to give them something to start building.
- 36:13And so it's always interesting to me on what hand we have a business and employees to we're giving away our thing.
- 36:19That turns out to be a pretty good business model these days, but it is a little bit.
- 36:22How does that work?
- 36:23And I think what you are offering is pretty helpful.
- 36:25Basically, the real, in addition to the core product, right, the real reason which you can go and sign up at Reflex.dev is take away the trouble of hosting this, upgrading it, maintaining it, patching it.
- 36:39Just push a button or a CLI command and your thing lives, right?
- 36:42Exactly.
- 36:43Yeah.
- 36:43We want to simplify the process of hosting because once you build your app, you end up having to host it anyways.
- 36:48And there's a lot of clouds out there, right?
- 36:51And we have self-hosting guides, so anyone that wants to can do that themselves.
- 36:55But a lot of these clouds, they're configured to host any type of app, right?
- 36:59Which is really great for the cloud because they can host anything.
- 37:01But for the user, it means it ends up being a lot of configuration, a lot of setup, and a lot of overhead when they just want to get their app and share it with someone.
- 37:10So one part of what we're doing with our hosting service is, one, making the UX around it really nice.
- 37:15So just a simple deploy command, your app is up and running.
- 37:18The second is we're really able to optimize our hosting around Reflex apps.
- 37:22Since it's the only type of app that we host, we can really optimize the performance, the cost, and all these other factors, as well as add a lot of stuff on top of it.
- 37:29For example, in the future, like analytics and different stuff on your app where that's another add-on if you're using a third-party hosting.
- 37:36So there's a lot of plugins on the open source side.
- 37:39But there's also, once you've hosted your apps, a lot of things you end up having to add in terms of analytics, tracking, monitoring, etc.
- 37:45So we have unification on the framework level, but also we're going to have it on the cloud level where every part of the framework and from the front and back into the hosting kind of knows about each other.
- 37:55So you can probably get some big machines and have a multi-tenant database with good performance, stuff like that.
- 38:00There's kind of two aspects to our hosting.
- 38:02One is a public cloud, and you can think of that similar to Vercel for Python.
- 38:06So that's more geared to, say, hobbyist startups, people that want to build their ideas shared with the public community.
- 38:12And another big use case, which is where a lot of our app developers come from, is the internal app use case.
- 38:20That's kind of another aspect where we're building tools to easily deploy to our internal cloud, monitor who's accessing your apps, etc.
- 38:27Yeah, I saw that over on Reflex.dev.
- 38:30If you go to pricing, it's basically free for hobbyists, coming soon for pro.
- 38:34You don't have anything to announce yet, do you?
- 38:35We're working on our pro hosting service.
- 38:38So right now, we have a hobby, so anyone can kind of deploy a few apps for free.
- 38:41But our pro is going to have features like custom domains, ability to configure your machines, multi-region, and make it actually like a crib.
- 38:49Let's a crib, probably.
- 38:49Yeah, yeah, SSL, all that.
- 38:51So actually making it kind of able to serve more users.
- 38:54I'm pretty fascinated by the idea that it's FastAPI in the back end.
- 38:58Because I'm always concerned that these things just don't scale.
- 39:00Like you're going to build it and it's awesome for 100 people.
- 39:02But then if it ever becomes popular, then it's a bad idea.
- 39:05You know, it just doesn't take it.
- 39:07That's a big reason also why we built our website as this is kind of the leading edge, cutting edge Reflex app.
- 39:12Like hopefully in terms of features and number of traffic, like it's tested our framework a lot in terms of like improvements to support it.
- 39:19I'm sure that it has.
- 39:20All right.
- 39:20Let's talk for a moment, for a few moments maybe, about what the programming model looks like.
- 39:27And just keep in mind, most people listening can't see what we're talking about.
- 39:30But nonetheless, let's just give people a sense of what it's like to write code in this.
- 39:34Okay.
- 39:35So if you go to Reflex.dev and scroll down, like just have a page or something, there's a little tab thing across the top here that has how do you create a form?
- 39:45How do you create a chat bot?
- 39:46How do you create an image gen?
- 39:48And, you know, this thing's pretty cool.
- 39:50It says, what do you want to see?
- 39:51And all this stuff is live, right?
- 39:52So I could be in here and type, I want to see a bunny.
- 39:54And within just a moment, boom, there's a bunny running on, what was it?
- 40:00I don't remember where I saw it.
- 40:01Running on Flux, right?
- 40:03Yeah.
- 40:03Yeah.
- 40:04Here it is.
- 40:04Flux schnell.
- 40:05Fast.
- 40:06The fast version.
- 40:07It's very fast.
- 40:08It's pretty fast compared to, I was playing with Mid Journey yesterday and, you know, that took a while.
- 40:13Then a lot of 500 errors and it took a while longer.
- 40:15Then eventually I got a picture out of it.
- 40:16Yeah.
- 40:16It was pretty cool.
- 40:17You got charts and so on.
- 40:19Let's maybe just talk about this little, send us a message, put your name, email.
- 40:24And message.
- 40:25What does it look like to code up one of these things?
- 40:28In all these examples you show, the code on the right is the entire code needed.
- 40:31So it all fits in one file.
- 40:33Like there's no extra stuff you need beyond that.
- 40:35So if you were to copy that and run it in an app, it would actually run.
- 40:38Yeah.
- 40:38And just to get people listening, there's probably 50 lines, 45 lines, something like that, a code.
- 40:44And so one thing you'll notice is it's all in one language and in this case, even one file.
- 40:48So it doesn't have to be in one file.
- 40:50Like you can have multi-page, et cetera, Reflex apps.
- 40:52But the kind of nice part is the front end and back end can live together in one repository.
- 40:57And so normally, you know, people that have written front end, they're probably used to either writing React HTML tags or, you know, templating through Jinja, et cetera.
- 41:06And what we kind of do different in Reflex is we define your front end as nothing but Python functions.
- 41:12So it fits in exactly with all the Python syntax.
- 41:15You don't have to kind of learn a new language there.
- 41:18Everything is a Python function.
- 41:19So for example, normally when you have a button, rather than writing an HTML button tag, we have built-in components like rx.button, which as you call it, will create a button.
- 41:30And the kind of layout of the front end, if you've ever worked with React, it's very similar to React or even HTML in the sense that you have this nested tree structure that kind of maps directly to the HTML DOM.
- 41:41And within there, you can define all your UI components.
- 41:45So that kind of is how the front end works.
- 41:47And once you define your UI, these Python functions compile down to React app in the end.
- 41:51Now, the interesting thing is how to make this interactive, right?
- 41:55Like how do you add state to this?
- 41:56So in this example, you want to do a form or in the image generation, I really want to hook this up with my OpenAI or my mid-journey model to create something.
- 42:04So normally in web development, you end up having to write a front end, a back end, and a networking layer between the two where you set up a FastAPI endpoint for every single action you want.
- 42:15Then on the front end, you're going to call that API, get the result by, parse it back, and then update your UI.
- 42:20So that's the normal flow of, say, even adding one new feature.
- 42:23Like if you want to add a button that generates an image and shows it, it will involve touching like multiple files, going through all this stuff, and hooking it together.
- 42:30So one thing that we've done in Reflex beyond bringing it to one language is abstracting away the front end, back end networking layer.
- 42:38So in Reflex, you'll never have to write an API call.
- 42:41You never have to write a post request, a get request, or any of that.
- 42:44All of that is done under the hood.
- 42:46So to set up your kind of state and interactive, you can do this all within what we call a state class.
- 42:53So a state class is just a normal Python class.
- 42:56And within it, you define all the fields in your state that can change over time, which we call vars, as well as any event handlers that can change the vars.
- 43:05So an event handler is just a Python-like function or method.
- 43:08And I think the image gen is a good example of it.
- 43:11So for example, in the image gen, the image URL is a var because it's something that's going to change.
- 43:15And an event handler would be the get image function, which is a function that when they hit submit on the input, we call it.
- 43:22So in order to hook up the front end and back end, all you have to do is hook up the UI to the Python function.
- 43:28So you can say button on click equals state dot get image.
- 43:32And what this does under the hood is when you click that button, it creates an event.
- 43:37It sends up through a WebSocket to the back end.
- 43:39It will run your Python function on the back end.
- 43:42So whether that's your OpenAI, your Replicate, whatever it is, all their state runs on the back end on a server.
- 43:48And that's what allows us to keep the state in pure Python.
- 43:50So it will update your state UI.
- 43:53In this case, it's going to update the image URL and send that back.
- 43:56And it works very similar to React in the sense that as your state updates, the front end updates reactively.
- 44:02That's super cool.
- 44:03Kind of just two-way data binding on the values there.
- 44:06Exactly.
- 44:06Yeah.
- 44:07All right.
- 44:07So you just said something interesting that there's the next JS React front end and the FastAPI back end.
- 44:13But you didn't say it's calling HTTP APIs.
- 44:16You said it's using WebSockets.
- 44:18Yes.
- 44:18What's the deal there?
- 44:19Why WebSockets and not Pydantic over HTTP or something?
- 44:23No, it's a really good question.
- 44:24And I think this is like, and a lot of people ask us, you know, how is Reflex's performance?
- 44:29Or what are the downsides of Reflex?
- 44:31Like, what's the catch?
- 44:32Because up to now, we've been saying, you know, we can perform, create anything you can do in JavaScript, anything you can do in React.
- 44:37So a lot of people are kind of ask about the performance.
- 44:40And we kind of made design Reflex to be really performant in everything we do.
- 44:44And the reason we use WebSockets is because Reflex apps, especially like very stateful apps, often need to make a bunch of requests.
- 44:51So rather than having to reestablish a new HTTP request every time, by keeping a WebSocket, we are really able to optimize the speed of the apps.
- 44:59So when you create, when you kind of send the type your prompt, say you want a bunny and you press enter through the website.
- 45:06We changed it to a fast bunny, by the way, because you said the website was fast.
- 45:09Now we have a fast bunny.
- 45:10So when you want that fast bunny, it will create a little event that says, hey, this guy wants to call get image and he typed fast bunny.
- 45:18It'll take that little payload, send it through the WebSocket that's already been established, run the Python function on the backend, and then send only the state delta back.
- 45:26So for example, if you have a really large app with hundreds of pages and hundreds of states, changing this is not going to say, hey, front end, this is their entire new state.
- 45:34We only send the diffs and stuff back over the WebSocket.
- 45:37So all of this was done like in the name of performance and making Reflex apps really snappy for whatever you're doing.
- 45:42In a sense, the Python code that I write, even though there's this React bit, some of it still lives on the backend.
- 45:49Yeah.
- 45:50And then some of it gets kind of mirrored to React on the front end.
- 45:53Is that right?
- 45:53This is something, especially like as people are learning Reflex, like one of the things we try to emphasize most, which is though it's all in one file, it's all in Python.
- 46:02There still is a distinction between the front end and backend because of this fact that the front end compiles to Next.js app while the backend is a FastAPI.
- 46:10So in this case, it's pretty much all the UI code, right?
- 46:13Like what's inside the index function.
- 46:15That's your Next.js React app.
- 46:17Your FastAPI is pretty much your state and your event handlers.
- 46:20So within there, you can keep everything in pure Python.
- 46:23use anything you want.
- 46:24The one thing you can't do and we can't do is compile arbitrary Python to JavaScript.
- 46:30So that's the reason all the event handlers run on the server.
- 46:33So you can use any library, anything you want.
- 46:35And on the front end, we only compile kind of a static website.
- 46:39So there's no logic that ever happens on the front end, actually.
- 46:42Just updating the bindings and triggering events.
- 46:45The front end is just like a dumb UI.
- 46:47It's like, give me the state.
- 46:48I'm going to show the state.
- 46:49That's definitely a nice bunny.
- 46:50So one thing that I think is notable here, and I've seen this in other frameworks as well.
- 46:55Like, for example, I had CuPy on Talk Python recently, which is also sort of React stuff on the front end.
- 47:04But this is a lot more, CuPy is more running, I think, React type stuff almost in PyScript, I believe.
- 47:12Oh, got it.
- 47:13All on there, which is interesting, right?
- 47:14But one of the things that I think you find with a lot of these is the shape of the code matches the DOM a lot of times.
- 47:22Or at least the conceptual idea of the hierarchy of the UI, right?
- 47:27So, for example, here you've got a VStag with a skeleton with a flex.
- 47:31And then you start putting forms and in the forms and all of this, every word that I said there is another level of indentation.
- 47:38And then you indent and you get a React input and a React button and you unindent Python style, right?
- 47:43And I think it makes it pretty easy to think about, here's the code, here's the UI, because the shape of the code matches the concept.
- 47:51It mirrors the UI in some ways, right?
- 47:53And rather than just pure top to bottom imperative, we're just generating the UI, but it actually, like, the way it's structured, it's kind of like Flutter.
- 48:01It looks like it matches it, you know?
- 48:03There's kind of two approaches people in this space have taken to building.
- 48:06Like, one is imperative, which is kind of what you said.
- 48:08And I think, for example, Streamlit has taken this approach where to do a button, you would do, like, ST heading, ST button.
- 48:15And it will implicitly, like, kind of magically put it into its thing.
- 48:18And I think it could be good for simple stuff, but it's really hard to reason about as your thing gets larger, because you have to kind of contextualize, wait, has this been called already?
- 48:27Like, what order is everything going through?
- 48:29Is the button in this group or is it outside of the group?
- 48:31Or, yeah, stuff like that, right?
- 48:33It's nice in some sense, but I don't think it scales very well, especially, like, conceptually.
- 48:38Like, it's hard to kind of reason about what all you've kind of built.
- 48:42I guess going back to, like, why it's in this structure, it's, like, this is already kind of the natural structure, right, from HTML, from React.
- 48:48And I think a lot of, as we were going through stuff related to API design, we try to improve the API where we can.
- 48:54But a lot of the times we realize, you know, the people that did it originally had a good idea.
- 48:58Like, and there's a reason it's kind of the standard.
- 48:59I think it takes a little getting used to, to be honest, to see search nested stuff.
- 49:03But I do like it.
- 49:04I think it's good.
- 49:05Part of it, I think in this example, we kind of nested it just to show, you know, it's all in one function.
- 49:08But in a more practical setting, you would break this up into different components.
- 49:12So similar to React, you probably wouldn't have a giant nested thing.
- 49:15And you can think of each of those things as units that you work with.
- 49:18Yeah.
- 49:18Also, like, decorators help a lot with, like, making dynamic components on the fly in terms of different functionality.
- 49:24Yeah.
- 49:24All right.
- 49:25Let's talk about just a couple more things while we're here.
- 49:27I want to talk about the components.
- 49:29And the components are these building block pieces.
- 49:32Maybe pick just a couple you think highlight the idea of these things and we can talk about them.
- 49:36A really big thing people use this for is kind of like tables and graphing.
- 49:39So maybe if you go down to the table section, the AG grid one might be a good one.
- 49:44So this is actually a good example of a third party component.
- 49:46So you can see we have our built in components, but a lot of our enterprise users really wanted this AG grid feature, which is one of the most popular kind of table libraries.
- 49:56So we make it really easy.
- 49:58This is an example of a third party library.
- 49:59Someone's wrapped that you can kind of bring in.
- 50:02And this is an easy way to kind of showcase your data.
- 50:05So a lot of data scientists, et cetera, use this library.
- 50:08It can hook up with your data frames and kind of show this.
- 50:11So this is another example showcasing kind of the flexibility of you want that random react library, even if it's not in Reflex, like the team or external contributor often wraps this easily.
- 50:22And yeah, the kind of nice part about it is it's more high level.
- 50:25It has a lot of these built in features like pagination, searching, sorting and all these.
- 50:28So I think it's this balance, right?
- 50:30Like we can give people the raw components like you can code everything in HTML.
- 50:35You can build everything from the ground up yourself or you can use this kind of high level thing.
- 50:40And the nice part about Reflex is you can kind of approach it at any level that you want.
- 50:44So it's like I want this nice built in thing that has sorting pagination.
- 50:47Here it is.
- 50:48Or you're like, you know, I'm just going to build everything from the ground up.
- 50:51I want my own table component.
- 50:52We also give you the tools to do that.
- 50:54So I think it just kind of shows the scale at which you can kind of pick your level of abstraction as you're using it.
- 51:00Yeah.
- 51:01Then you just pip install the name of the thing and then just use it like a native component, right?
- 51:07Exactly.
- 51:07And it will act as if like all other Reflex components.
- 51:10So there's nothing like distinct between our components and something you would wrap yourself.
- 51:13I was a reasonably sized company with a team of maybe many of them knowing React.
- 51:20It might make sense for me to build out an internal library of widgets that we use on our app and plug in to Reflex something like that.
- 51:27We have a whole guide on our website on wrapping React with different examples.
- 51:31And we're trying to make it accessible for Python developers.
- 51:34So because that's our user at the end, right?
- 51:36So we wanted to make it accessible for even a non-JavaScript, non-React expert to be able to wrap these components.
- 51:42So we've seen in different companies, like I kind of mentioned earlier, that have their internal component systems in React.
- 51:49A Python developer was easily able to kind of wrap these because we make it super easy to wrap as just a Python class where you just define the props.
- 51:57So maybe if you go to the wrapping React section on the left-hand side, it's kind of at the, maybe go back to the main docs section.
- 52:05But yeah, we try to make it really easy to bring your own components as well.
- 52:08So whether you already have one or you want to make your own.
- 52:11So this is like a spline one.
- 52:13And you can see all you have to do is list all the props.
- 52:15It's a Python class.
- 52:17You kind of have to just go find what library, what npm library you're using, list all the props.
- 52:21And for interactive ones, you may have to define that.
- 52:23And then you can start using it right away.
- 52:25As part of your component, you define just basically the npm thing to install or whatever.
- 52:30And then off it goes.
- 52:31Yeah.
- 52:31And Reflex will handle, it'll install the component.
- 52:33It will wrap it for you and it will compile out for you.
- 52:35All right.
- 52:35I said three things.
- 52:36One was components.
- 52:37The other is this AI generator.
- 52:39And then I want to just talk about the roadmap.
- 52:41So let's get short on time.
- 52:42So let's go and talk about this FlexGen thing.
- 52:46This is build web apps at the speed of thought.
- 52:49Create UIs with Reflex framework with simple prompting.
- 52:53This is in beta.
- 52:53Like we're kind of released it on our Discord and we're going to do more releases.
- 52:58But this version of it is similar to if you've seen like v0.dev from Vercel.
- 53:04This is kind of, I'd say like a version of V04 Reflex where you can, it's a web editor.
- 53:08You can enter your prompt.
- 53:09It's going to live stream your output.
- 53:11At the end of it, it's going to give you the code that you can copy into your app and you
- 53:15can start adding a backend to it.
- 53:17So I guess an important note is this is more for like your starter app, right?
- 53:20Like when you're first starting your project and you want to get like a good starting point.
- 53:24We'll fix that.
- 53:25So don't worry about it.
- 53:26It made such a nice one for me before.
- 53:28Let's see.
- 53:28Yeah.
- 53:29The idea of this one is to be kind of a web editor to get your app kind of started building
- 53:33out from.
- 53:34And this is kind of just a version of V0 for Python.
- 53:37So this is level one of what we're building with FlexGen.
- 53:40But a more interesting thing that we're developing now internally and are hoping to release in
- 53:45the next month is a local version of this.
- 53:47So this is, this has no context of your existing code base.
- 53:50It has no context of what you're building, right?
- 53:52So you could ask it to build a little component, but a big issue with V0 and other of these web
- 53:56developers is how do I actually integrate this into an existing app?
- 53:59Like it's good at building brand new stuff, but how do I like update an existing app?
- 54:04So on this front, we're building a local AI toolbar, which has a lot of these agentic
- 54:09features around Reflex, but on your local.
- 54:11So for example, the features we have there are you can click a button and say, when I click
- 54:16the button, do this or click a text and say, change, like, you know, put a form under this
- 54:20text.
- 54:20And the big idea there, I think this is a good, good first start, but I think in the long
- 54:25run, I'd see the toolbar as being this way where the AI and the developer kind of integrate
- 54:31together with Python as a common language.
- 54:33So for crazy stuff that you don't want to deal with, like make a form that works in mobile
- 54:37view, et cetera.
- 54:38The AI can handle a lot of this, but once it outputs, it's outputs code that you can actually
- 54:43go understand and read.
- 54:44Like it's not this obfuscated JavaScript or React code.
- 54:47It's code that you can go edit by hand if you want, and you can easily hook up your own
- 54:51state and data to it, right?
- 54:52Which is a big other thing.
- 54:53I think other frameworks miss, which is here's a great dashboard.
- 54:56Great.
- 54:56But it's all fake data.
- 54:57Like how do I actually make it hook up with my clicks, hook up with my different data?
- 55:02So that's a big part of what we're trying to bring to the local environment.
- 55:05This thing will generate a visual look and feel thing and you actually go show the code.
- 55:09That's all fake data.
- 55:10Yeah.
- 55:11And then it's fake.
- 55:11Yeah.
- 55:11Yeah.
- 55:11Of course.
- 55:12And then you can show the code and then now you can kind of copy the code, start using
- 55:15it in Reflex.
- 55:16And then with the toolbar, you'll then be able to make incremental upgrades on top of this
- 55:20rather than starting from scratch.
- 55:21And that will have like full context.
- 55:24And on top of that, we're aiming to build a lot of stuff on top beyond, you know, just
- 55:29prompting and updating.
- 55:30Like there's a lot of improvements that we want to build on top of that as well.
- 55:33All right.
- 55:33Well, this is pretty neat.
- 55:34I like it.
- 55:34It definitely gives you some ideas for here's some possible layouts and so on.
- 55:39And it gives you at least a little bit of an idea of what you might want to do and take
- 55:42it and run with it.
- 55:43So that's helpful.
- 55:44Yeah.
- 55:44I think some ideas we have in the future for the local are, you know, buttons that can,
- 55:48you know, keep your same content, show you different variations, like auto style it, etc.
- 55:51Like a lot of stuff that people don't want to deal with, but they're like, just give me
- 55:55some ideas and how it could look and turn people more into like, you know, prompters and
- 55:59selectors rather than implementers.
- 56:00All right.
- 56:01Let's close it out with the roadmap.
- 56:02Where are we going?
- 56:03So recently we just released Reflex 0.6 last month.
- 56:07And right now we're going after 0.7.
- 56:10So a big part of 0.7 is cleaning up a lot of our core components that we have, especially
- 56:15for the features people use the most.
- 56:17So the ones we're starting off with are like you can see here, AG grid support, which is
- 56:22a big thing people asked.
- 56:23And beyond that, just like very good support with tables, databases, and graphing to help
- 56:29a lot of these internal apps and data science use cases.
- 56:32Beyond that, like one really important thing for web frameworks that we're trying to build
- 56:36is auth.
- 56:37So built in auth.
- 56:37So if anyone's ever used Django, you know, they have a really great kind of way that you
- 56:42can plug any auth system in.
- 56:43And that's often the first thing someone wants in a practical web app, right?
- 56:47They're like, I have, especially a data app.
- 56:49They're like, I have this great app, but I don't want anyone to be able to access it.
- 56:52And we already have integrations with third party auth providers.
- 56:55But we want to bring in just like first party auth where you can just add a click of a button.
- 56:59Your website is going to have auth at this point.
- 57:01A lot of these, the other stuff here is related to a lot of performance improvements that we're
- 57:07going to make.
- 57:07So one key feature of Reflex is the development experience.
- 57:11So one part of that is code, but the other part is things like hot reload and how fast is
- 57:15it for me to actually make iterations on what I'm doing?
- 57:18So a lot of these other tickets are internal changes we're going to do to make it easier for
- 57:23pretty much improve the hot reload times.
- 57:25So we wanted people to improve their iteration speed a lot.
- 57:28A lot of time people like pretty much all their time should be spent looking at actions and coding
- 57:32and not waiting for anything.
- 57:33And then one final thing related to kind of how we want to simplify the approach of UI and state
- 57:39is we're implementing a system called CSR, which is kind of right now,
- 57:45I kind of mentioned there's this difference between compile time and runtime.
- 57:49And there's certain things, your entire UI kind of needs to be known at compile time.
- 57:53So you have to compile your code and that's what you get at runtime.
- 57:56And what we're introducing is this idea of dynamic components, which are dynamics generated at runtime.
- 58:02So this will enable a really cool use cases.
- 58:05For example, you can have a chat bot that instead of just returning text all the time,
- 58:08it could return components.
- 58:09So it could return a graph, it could return a whole Reflex page.
- 58:12And these could be components that you don't know upfront and are actually generated during runtime.
- 58:16So it's going to help a lot in terms of flexibility and also in terms of, you know,
- 58:21the ease of use in using Reflex, because since they're generated at runtime,
- 58:25you can now use pure Python.
- 58:26You don't have any limitations.
- 58:28And there's a lot of advantages on the developer side as well.
- 58:31Yeah, that's very cool.
- 58:32So yeah, this is on the open source.
- 58:33And we're also, like I mentioned, releasing some of our AI features.
- 58:36And the biggest thing, though, is we're releasing our first version of our hosting service.
- 58:41Our hosting service has been in beta for some time right now.
- 58:43But along with all this, we're releasing our first kind of paid version of our hosting service.
- 58:48And yeah, getting people on apps onboarded onto there is coming up.
- 58:53So I'm really excited for that.
- 58:54Framework looks really nice.
- 58:55So sure to help a lot of people.
- 58:56Awesome.
- 58:57All right, guys.
- 58:57One final parting thought from each of you.
- 59:00Yeah, I can go.
- 59:01I think one of the fun things that I've experienced with working here is that
- 59:05even when I'm writing our docs,
- 59:07it's like some people have never interfaced with props before.
- 59:11And so Reflex, in a way, is like a bridge to the web ecosystem.
- 59:15So it's been fun thinking about what are the mental models that I can take in Python
- 59:20to help explain things that are in web?
- 59:23And it's like, how can we bring those in and then create pathways
- 59:26for people to start building apps?
- 59:28Yeah, there's not a lot of event-driven stuff in Python,
- 59:30but so much of the web is event-driven callbacks and stuff.
- 59:34Yeah.
- 59:34I'm just excited about thinking about new kind of user interfaces,
- 59:37both in terms of like coding APIs and, you know, actual user interfaces
- 59:41that people are going to be able to build upcoming.
- 59:44I think the current web frameworks, you know, the Django's and Flask,
- 59:47they've been around for a long time.
- 59:48And I think they have a lot of great stuff,
- 59:50but there's also a lot of new stuff that I think a next generation of web frameworks
- 59:53could like add, you know, to accelerate a lot of work.
- 59:57And I'm just excited about thinking of what are those features?
- 1:00:00Like how can we accelerate while keeping the good stuff that's already been,
- 1:00:03you know, discovered before?
- 1:00:04And yeah, I think there's, especially now, like a lot more people are building,
- 1:00:08a lot more people are becoming builders and sharing.
- 1:00:10So I'm excited about like empowering all those people.
- 1:00:12Yeah.
- 1:00:13There's a lot of abstractions to like think through in terms of like,
- 1:00:16like how can we create guarantees that can enable someone to be successful in the long term,
- 1:00:21especially when it comes to building apps that can serve like hopefully millions of people
- 1:00:26and millions of traffic, but then also like being flexible enough that they can still start.
- 1:00:30That's a challenge.
- 1:00:31And you know, there's a lot of places that are struggling with those challenges or trying to solve them.
- 1:00:36Look at AWS.
- 1:00:37Just go to the services tab of AWS, right?
- 1:00:40That place serves tons of people, but boy, is it complicated to look at the hundred or whatever services
- 1:00:47and decide what you need and how they go together, right?
- 1:00:49We have system initiative now though.
- 1:00:51So that's going to be huge value add.
- 1:00:53Yeah.
- 1:00:54I think in one way, I think we're, we're on an effort to just like simplify this whole thing
- 1:00:58and yeah, just make it really easy for more people to build.
- 1:01:00Yeah.
- 1:01:01It's a good mission.
- 1:01:01All right.
- 1:01:02Nikhil, Elvis, thanks for being on the show.
- 1:01:03Talk to you guys later.
- 1:01:04Yeah.
- 1:01:05Thanks so much.
- 1:01:06Bye.
- 1:01:06Bye.
- 1:01:06This has been another episode of Talk Python To Me.
- 1:01:10Thank you to our sponsors.
- 1:01:12Be sure to check out what they're offering.
- 1:01:14It really helps support the show.
- 1:01:15This episode is sponsored by Posit Connect from the makers of Shiny.
- 1:01:20Publish, share, and deploy all of your data projects that you're creating using Python.
- 1:01:24Streamlit, Dash, Shiny, Bokeh, FastAPI, Flask, Quarto, Reports, Dashboards, and APIs.
- 1:01:31Posit Connect supports all of them.
- 1:01:33Try Posit Connect for free by going to talkpython.fm/Posit, P-O-S-I-T.
- 1:01:39And this episode is brought to you by Bluehost.
- 1:01:42Do you need a website fast?
- 1:01:43Get Bluehost.
- 1:01:44Their AI builds your WordPress site in minutes and their built-in tools optimize your growth.
- 1:01:50Don't wait.
- 1:01:51Visit talkpython.fm/bluehost to get started.
- 1:01:54Want to level up your Python?
- 1:01:56We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:02:00Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:02:05And best of all, there's not a subscription in sight.
- 1:02:07Check it out for yourself at training.talkpython.fm.
- 1:02:11Be sure to subscribe to the show.
- 1:02:12Open your favorite podcast app and search for Python.
- 1:02:15We should be right at the top.
- 1:02:17You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 1:02:22and the direct RSS feed at /rss on talkpython.fm.
- 1:02:26We're live streaming most of our recordings these days.
- 1:02:29If you want to be part of the show and have your comments featured on the air,
- 1:02:32be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:02:37This is your host, Michael Kennedy.
- 1:02:39Thanks so much for listening.
- 1:02:40I really appreciate it.
- 1:02:41Now get out there and write some Python code.
- 1:02:43I'll see you next time.