Latest / Talk Python To Me / #13: Flask web framework and much, much more
Transcript
- 0:00Grab your micro framework and pour some web into your flask.
- 0:03It's time for Talk Python To Me, episode number 13 with guest Armin Roenacker.
- 0:08Recorded Monday, May 29th, 2015.
- 0:11Hello and welcome to Talk Python To Me,
- 0:40a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
- 0:46This is your host, Michael Kennedy.
- 0:48Follow me on Twitter where I'm @mkennedy and keep up with the show and listen to past episodes at talkpythontome.com.
- 0:55This episode, we'll be talking to Armin Roenacker about Flask, Python, the web, and Rust.
- 1:02I'm really fortunate to have CodeChip and Hired sponsoring the show.
- 1:07Let me take just a few seconds to tell you about them.
- 1:09CodeChip is a platform for continuous integration and continuous delivery as a service.
- 1:15They encourage you to always keep shipping.
- 1:18Please take a moment and check them out at codeship.com or follow them on Twitter where they're at codeship.
- 1:23Hired wants to help you find your dream job.
- 1:26Hired is built specifically for developers looking for new opportunities.
- 1:30Check them out and get a very special offer at hired.com slash talkpythontome.
- 1:35And you'll find them on Twitter where they're at hired underscore HQ.
- 1:39Now for a few announcements.
- 1:42First, the Talk Python To Me t-shirt is here.
- 1:45I talked about the possibility of a Talk Python To Me t-shirt a few shows back.
- 1:49Well, there were enough requests to make this a reality.
- 1:53And today, I'm happy to tell you that a pretty sweet shirt awaits you at bit.ly slash python shirt.
- 1:59It's a Kickstarter project, but because you guys are so awesome, the Kickstarter was funded within three hours of my announcing it on Twitter and before I could even properly announce it on the air.
- 2:09So if you visit the Kickstarter, you'll find there's three tiers.
- 2:11One is the shirt, of course.
- 2:13But there are other options that get you a promotional spot on the show.
- 2:16So if you have a product, website, or company you want to get the word out about, here's your chance.
- 2:21Also, before we get to the interview, there's a few additional guests that made a cameo appearance in the show.
- 2:27I'll let them introduce themselves.
- 2:37Seriously, there is a horse and some birds in this episode.
- 2:39Didn't mean for that to happen, but with the crazy time zones between Germany and the U.S. West Coast, we recorded this episode somewhat out in nature in the evening for Armin.
- 2:49I hope you don't mind the extra guests.
- 2:51Now let's get on to a great show.
- 2:53Armin, welcome to the show.
- 2:56Hello.
- 2:56Thank you so much for being on my show.
- 2:58I'm a big fan of Flask, and I think it's one of the most used web frameworks out there in the Python space.
- 3:04And I'm really excited to talk to you about it today.
- 3:07Yeah, sounds good.
- 3:08I'm always glad to share.
- 3:10Yeah, great.
- 3:11And we'll talk a lot about the details of Flask and some of the other projects you're working on.
- 3:15But before we get to them, you know, people are always wondering, you know,
- 3:19everyone who's really accomplished a lot in their programming career like you have, you know, how did you get started?
- 3:24Where do you start programming?
- 3:26How do you get inspired to do this kind of stuff?
- 3:28I think for me, it didn't really start anywhere.
- 3:33It just gradually became more and more.
- 3:36So I just had an interest in technology and programming.
- 3:41And I just quite early on figured out that they're computers and you can do stuff with them.
- 3:47And then it just grew.
- 3:49So it's actually very hard for me to figure out where exactly I started in Python.
- 3:53It definitely wasn't the first programming language I used, but it was one of the earliest ones I used in a proper way.
- 4:02Sure.
- 4:02Do you remember what you started with before Python?
- 4:05Oh, I know that the first thing I ever used was Quick Basic.
- 4:08That's what I found.
- 4:10Quick Basic was the one with the line numbers, right?
- 4:15Like 10.
- 4:16No, no, no.
- 4:17It didn't even.
- 4:17No, no.
- 4:18It had proper structures.
- 4:19Did it?
- 4:20Okay.
- 4:20You have functions and everything.
- 4:21Although I did use GoTo, but to go to label and not go to line number.
- 4:26It was actually quite good.
- 4:27Yeah, yeah.
- 4:28That's good.
- 4:28And then I found Pascal.
- 4:32And there was a version you can run on Windows, which is called Delphi or Delphi.
- 4:37And I used that.
- 4:38And then I found Python.
- 4:40And that just...
- 4:42It's not even true.
- 4:44I used PHP before.
- 4:45That's how I got into web development was that I found Python and PHP sort of at the same time.
- 4:51And I tried to make Python more into PHP.
- 4:54Because when I started using Python originally, there was...
- 4:58So when I started using Python originally for web development, Django didn't exist yet.
- 5:04It kind of was starting to...
- 5:07So there was a Python talk, a Python talk, I think.
- 5:09And then it came out in 2005 or something.
- 5:13And I was...
- 5:15At the time, I was trying to make just web applications with just CGI and stuff like that.
- 5:22Right.
- 5:22And then that's how I figured out that WSGI is a thing.
- 5:26It was just drafted up as a PEP at that point.
- 5:29And then I just got interested in how it works.
- 5:31And that's how I ended up doing Python properly, I guess.
- 5:35Yeah, that's cool.
- 5:36So what do you do today for work?
- 5:39That's complicated.
- 5:42So for the last three years, I have worked at a gaming company in London.
- 5:48And there was a lot of Python, obviously.
- 5:51Because we're doing...
- 5:53That's what I do professionally, obviously.
- 5:55But a lot of the stuff we did there was very game-related.
- 6:00So we built server infrastructure for computer games with Python and just general databases.
- 6:06But then also quite a lot of stuff on the game side itself.
- 6:12So the last project I worked on before the stuff I'm doing currently was helping out with the Halo Master Chief Collection.
- 6:24And that was mostly client-side.
- 6:26So it was more C++ than Python.
- 6:28Yeah.
- 6:29On the client-side, when you're doing games, there's a lot of C++.
- 6:31Did it have an online component, a web component?
- 6:35Yeah, there's lots of web stuff nowadays in these computer games.
- 6:38Like, everything is in the cloud.
- 6:40So there's lots of HTTP and everything.
- 6:43And now, with sort of the beginning of the year, I'm doing both the computer-side thing, computer-game-side thing still.
- 6:52But also working on Sentry now, which is an online error-reporting tool.
- 6:58Excellent.
- 7:00That sounds...
- 7:01Yeah.
- 7:01Yeah.
- 7:02I think you might have seen that.
- 7:03It is a Django project.
- 7:05And it's quite popular in the Python community.
- 7:08Yeah, yeah.
- 7:09So that's why I spend some of my time on now.
- 7:11Yeah, it's really great.
- 7:12We'll put links to those in the show notes.
- 7:15Can you say the name of the game that you're working on?
- 7:16So the last game I was working on was Halo the Master Chief Collection.
- 7:21And I can't say what I'm doing currently.
- 7:22Yeah, okay.
- 7:23Great.
- 7:24Sounds like a lot of fun, though.
- 7:26So the thing that I sort of know you for out in the community is Flask.
- 7:31What is Flask?
- 7:33And how do you get started with that?
- 7:36So Flask in itself is the end result of just taking a bunch of stuff that I built before
- 7:44and make it into a proper framework.
- 7:47So Flask in itself can be used for building sort of any web application you want to do.
- 7:52It's sort of the base building block you can put the application on top.
- 7:56But Flask is not the...
- 7:59When Flask came out originally, it was pretty much empty
- 8:04because it's sitting on top of two or more than two.
- 8:08I think it's like three base libraries.
- 8:09It's Werkzeug, which is a WGRI implementation,
- 8:14which does the HTTP handling so that you can get your form data parsed.
- 8:20You can get access to your cookies and all that sort of stuff.
- 8:22And then Jinja, which is a templating engine,
- 8:25which originally started out as an evolution of the Django templating engine.
- 8:31And then it's sitting on top of markup safe and it's dangerous.
- 8:35These are two libraries which are dealing with security-related things
- 8:40just to keep HTML safe and to sign your cookies to keep them safe from tampering with.
- 8:47And that's what Flask is.
- 8:50So it's basically a combination.
- 8:52It configures three base libraries I wrote before into a coherent package you can get started with.
- 9:01All right.
- 9:02That's really cool.
- 9:03What were you using before Flask that kind of inspired you to create this framework?
- 9:06Was that Django or something else?
- 9:09So I was always using my own libraries, which was Werkzeug, Jinja, It's Dangerous.
- 9:14Basically, What's Sitting...
- 9:15It's Dangerous came afterwards, but there was an implementation of that before.
- 9:19So these were always these libraries which I wrote before, which I was using,
- 9:24but they were never really all that popular.
- 9:26And then people started doing this one-file micro-frameworks,
- 9:30and I started doing an April's full stroke,
- 9:33where I basically took all the libraries I had and put them into a zip file,
- 9:36Bay64 encoded them into a Python file,
- 9:39and then I distributed one Python file, which included all my libraries.
- 9:43Oh, nice.
- 9:44And I made an April's full stroke with screencast and everything about it.
- 9:48And what I learned there is that that actually got really popular,
- 9:52and it didn't actually get popular because people realized it was an April's full stroke.
- 9:56It got popular because there was a little bit of marketing behind it.
- 10:00So I took that sort of lesson and applied it to making a wrapper around my libraries,
- 10:05which I called Flask, and I wrote good documentation for it, made a website,
- 10:10and I just promoted it a little bit, just at conferences and just shared it with people.
- 10:18And that then got a lot more popular than the libraries themselves were.
- 10:22So that's how Flask actually happened.
- 10:25It was more sort of the first push to try to make it into something that people would actually use,
- 10:32and not just me.
- 10:32So you have these little separate libraries.
- 10:34They were all useful, but it was the putting them together as like a coherent whole
- 10:38that kind of made it really interesting in the community.
- 10:40Yeah, I think so.
- 10:42I mean, there's still probably more people that use the base libraries than actually use Flask,
- 10:46but Flask is the one thing that you can easily find now.
- 10:51Yeah, for sure.
- 10:52And it's very popular.
- 10:53You know, on GitHub, you've got over 14,000 stars, over 4,000 forks.
- 10:57You must be pretty proud of it.
- 10:59Yeah, it's pretty cool that it took off this way.
- 11:02Yeah.
- 11:03Nice.
- 11:03When did you release it originally?
- 11:05Ah, I don't know anymore.
- 11:07I know that it was a couple of, I think it might have been like two or three months.
- 11:12No, even probably less than a month even after it was full stroke.
- 11:17That was probably, I don't know, six years ago now?
- 11:20Yeah.
- 11:21I can't remember.
- 11:22It would actually be interesting.
- 11:23Oh, it's not even one pounder.
- 11:26Yeah, you've got to celebrate his birthday or something like that, right?
- 11:29Yeah, I'm not that attached to actually celebrating things.
- 11:35Sure.
- 11:36So one thing that...
- 11:382010.
- 11:38So that sounds at all.
- 11:40Yeah, okay.
- 11:40So it's five years.
- 11:42Almost five years.
- 11:43Exactly, right?
- 11:44Because it's a...
- 11:45Yeah, made it for 12.
- 11:47Yeah.
- 11:48Great.
- 11:49Okay, so perfect.
- 11:51Five years.
- 11:51Five years.
- 12:05CodeChip is a hosted, continuous delivery service focused on speed, security, and customizability.
- 12:10You can set up continuous integration in a matter of seconds and automatically deploy when your tests have passed.
- 12:16CodeChip supports your GitHub and Bitbucket projects.
- 12:19You can get started with CodeChip's free plan today.
- 12:22Should you decide to go with a premium plan, Talk Python listeners can save 20% off any plan for the next three months by using the code TALKPython.
- 12:31All caps, no spaces.
- 12:33Check them out at CodeChip.com and tell them thanks for sponsoring the show on Twitter where they're at CodeChip.
- 12:40One thing I thought would be interesting for people, even though it's a little hard to do, is maybe just describe a little bit of the type of code that you have to write.
- 12:52I suspect many people out there have written Flask apps, but also many of them haven't.
- 12:57So, like, how do I get started?
- 12:59So, I guess the easiest way to get started with it is to download it from pip, which is what most people use now.
- 13:05Set up a virtual env, get pip, install Flask in there, and then you can probably even just go to the front page of Flask and copy-paste the Hello World example.
- 13:15And that's probably good enough to get going, which is really not that much.
- 13:19It's like four lines of code.
- 13:20So, it's quite straightforward, and it comes, like most Python frameworks, with a local development server and pretty much all the stuff you need.
- 13:28You basically create an instance of the Flask class, you give it a name, and you call run on it, and you map some routes to some methods and things like that, right?
- 13:37Yeah.
- 13:38So, I think one of the things I wanted to do with Flask was to show people what's a better idea to structure an application compared to how you do it in Django, for instance.
- 13:49Because if you have used Django, Django has this huge config problem.
- 13:55Where they have this module, it's called Django Conf Settings.
- 13:59And it's one global object which holds all your configuration, which basically means that in one Python process, you can only run one application, because they would touch each other's config settings.
- 14:10So, with Flask, I wanted to show that you can do it differently as well, where in Flask, you have to create an instance of Flask.
- 14:17And you can create multiple instances, and they can be living entirely separate of each other.
- 14:22So, that's why you have to create this Flask object, because you configure that Flask object.
- 14:28And it's actually really nice, the effect to get out of this.
- 14:32I mean, Flask is obviously not the first framework that does that.
- 14:35I mean, that's a general really good pattern for development.
- 14:37But I think it was definitely one of the frameworks that popularized this idea of creating an application object,
- 14:45and then configuring that application object instead of just changing some configuration, which is entirely detached from what you're doing somewhere else in the Python process.
- 14:55Yeah, I really like that way that you're doing that as well.
- 14:58And does it help with testing and things like that?
- 15:01Yeah, definitely.
- 15:02Especially the test for Flask itself.
- 15:06I mean, they create like 500 different individual Flask applications and test them, which is a lot nicer to work with than trying to do test separation on Django,
- 15:15where you're never quite sure if the last test run actually reset everything to the state you thought it should be.
- 15:23So, it's very nice that you can actually create those applications and guarantee that they will be separate of each other.
- 15:29Sure.
- 15:29So, you just don't know if there's some sort of order dependency in your Django test, because it's really the same one, right?
- 15:36Mm-hmm.
- 15:36Okay, that's really cool.
- 15:38You've been talking about Django.
- 15:39There's some other web frameworks that come to mind as well, like Pyramid is probably the other major one that comes to mind for me.
- 15:46Can you sort of compare and contrast what it's like working in those different environments?
- 15:50Like, what is special about Flask over, say, Django or Pyramid?
- 15:54I don't know.
- 15:56It's very hard for me to say now, because I have been using...
- 16:00Like, originally, when I started doing Flask, or even before that, when I just wrote the base libraries, there was a really, like, an almost war going on between the different frameworks and the popularity between them.
- 16:13And a lot of that had to do with that Whiskey as a standard was not very well established at that point.
- 16:20For instance, a lot of developers deployed the Django applications with ModPython.
- 16:27And even if they did use ModWhiskey to deploy them or just any other WSGI server, there was no real way to interact with Whiskey in Django.
- 16:37So you couldn't add any Whiskey middlewares.
- 16:39There was...
- 16:40Basically, people wrote their libraries very, very specific to frameworks.
- 16:45Flask Stephanie was a framework that did it differently, because it promoted the idea of you actually write library against no framework at all.
- 16:55You just try to write your library in a way that makes it work in an isolated way.
- 17:01And then later on, you make an extension, and then you bind your library as conveniently as possible for the framework you want to use it with.
- 17:09And I think that is...
- 17:11Flask was probably not the first one which did it, but I think that is a much better situation to be in now, because many libraries do not require to be in the context of a specific framework.
- 17:23So at this point, I think it's very irrelevant which framework you actually use, because you can use pretty much all the functionality in the Python ecosystem in any of those frameworks.
- 17:33There might be small differences in how it works, but it's definitely very different than how it was in 2007 or 2008, when some functionality only existed within Django, for instance.
- 17:45Or you had to use TurboGear or something of that sort.
- 17:48So I think that is different now.
- 17:51And at this point, the framework is such a small part of your overall development experience that whatever floats your boat, I guess, is a good way to get started.
- 18:03And then after some period of time, you probably will end up modifying the framework you're using anyways.
- 18:10So, yeah.
- 18:11I don't know if that answers the question about comparing those frameworks.
- 18:15No, but it's an interesting answer for sure.
- 18:17I think it does somewhat answer it.
- 18:19But, I mean, it's interesting to say that for the most part, it's not as front and center as it used to be.
- 18:28Yeah, I don't think it's front and center at all.
- 18:29Especially both Flask and Pyramid have the same general idea of...
- 18:35I mean, Pyramid is very different.
- 18:36But both of those systems have the idea that it's sort of a layered cake.
- 18:42And at the very bottom, you have Whiskey.
- 18:44And then one layer above that, you have a base implementation of Whiskey, which in case of Flask is Werkzeug.
- 18:50And in case of Pyramid is WebOp.
- 18:53And you can sort of reach through and then slice away every single layer you don't want to use and dig a little bit deeper.
- 19:01Django doesn't do it just as much because of its long history of re-implementing everything for itself.
- 19:07But even if you can't use a certain functionality in Django, you can still go and use Flask together with Django if you would need to do that.
- 19:17And so in that sense, I think it's a lot less important now to pick a framework as it is or as it was before.
- 19:25Right. Okay, cool.
- 19:27So you said you created this in 2010.
- 19:31The way people write web apps today is fairly different than the way it was in 2010 and certainly before then.
- 19:37What's your thoughts on that?
- 19:40Yeah.
- 19:40So I think that Flask doesn't actually do a really good way in staying on top of things in that sense.
- 19:48So obviously, now there's a lot more JavaScript, for instance, in web development.
- 19:56And the idea of rendering something on the server is now almost like a holy war.
- 20:00Like, should you do it?
- 20:01Should you make React everything?
- 20:04Should you use Angular?
- 20:05I don't know.
- 20:05So especially in that environment, there is so much change happening currently that I'm sort of on the side a little bit of just seeing what happens.
- 20:15I made two terrible technology choices in the last three years by trying to use Angular, which then turned out to just not make sense in the way I was using it.
- 20:25Or maybe not even in the sense how Angular 1 was implemented.
- 20:30And then I don't even know what the other thing was.
- 20:32Maybe it was Backbone.
- 20:33I can't remember.
- 20:34But basically, the JavaScript world is moving so very fast in trying to change the whole infrastructure that right now it's actually really hard to make a good decision in regards to how you should build it.
- 20:47It's actually very good to be a little bit more conservative and try to pick something which hasn't been, is not entirely the latest thing that's happening because you just run at risk of that thing changing so quickly while you need to use it.
- 21:01But I do think that there's a, so generally, like, the way I use my own software at my work is very different than how most people use Flask.
- 21:13Because, for instance, at Fireteam, which is the London-based gaming company I work for, we basically build infrastructure by, when we have front-end UIs, they sit on top of an API server, which then talks to a remote API server.
- 21:28So it's a very layered situation you have there.
- 21:32And that is getting more and more common, that you basically build services out of plugging individual APIs together.
- 21:39I wouldn't necessarily call it service-oriented architecture, but it does kind of go that way.
- 21:43And that is definitely getting more popular.
- 21:47And I think that is probably an area where Flask will develop into the moment it becomes clear that this is something that makes sense.
- 21:55But you can already do that today.
- 21:57There's so much stuff that you can plug into Flask that will support you in writing APIs and then putting front-end UIs on top of that, instead of actually going and just delivering HTML to the client directly.
- 22:11Yeah, I think one of the things that really impresses me about Flask is all the stuff that people are layering on top of Flask to write really cool applications.
- 22:22Yeah, I think it's a good thing that Flask itself, it did grow in size, but it's still very, very small and tiny.
- 22:31And there's a lot more that actually exists in the ecosystem that doesn't exist in Flask itself.
- 22:36Right.
- 22:37One of the ones I was thinking of is this thing called Eve by a guy named Nicola Hiroshi.
- 22:41He was one of our first guests, actually.
- 22:44And that's like a REST API on top of Mongo and SQLAlchemy and so on that has Flask as the base.
- 22:49What else is out there like that that I can add in and maybe create a RESTful system or whatever else that you've seen that's pretty cool?
- 23:08This episode is brought to you by Hired.
- 23:10Hired is a two-sided, curated marketplace that connects the world's knowledge workers to the best opportunities.
- 23:17Each offer you receive has salary and equity presented right up front and you can view the offers to accept or reject them before you even talk to the company.
- 23:26Typically, candidates receive five or more offers in just the first week and there are no obligations ever.
- 23:32Sounds pretty awesome, doesn't it?
- 23:34Well, did I mention there's a signing bonus?
- 23:37Everyone who accepts a job from Hired gets a $2,000 signing bonus.
- 23:41And as Talk Python listeners, it gets way sweeter.
- 23:45Use the link Hired.com slash Talk Python To Me and Hired will double the signing bonus to $4,000.
- 23:52Opportunity's knocking.
- 23:54Visit Hired.com slash Talk Python To Me and answer the call.
- 24:06So the thing is, I'm not using Flask extension myself much.
- 24:10I don't know.
- 24:11I like the idea of having as much control as possible over what I'm doing.
- 24:16And unless I'm not using it, I'm not using it.
- 24:21I'm probably not necessarily going to use it.
- 24:23So I use a ton of the database integrations like Flask and Quarkomy, obviously, because I'm a friend of Postgres.
- 24:30So that's sort of my database of choice.
- 24:32So these little extensions that just make it very easy to connect to a database, I use them pretty much all.
- 24:40There is the Flask security, which gets you quite far in just setting up an authentication layer and getting the most problematic security problems out of your way.
- 24:54What else am I using?
- 24:56I'm using Flask WTF just because it's good enough.
- 25:00It's maybe not the best extension in the world, but if you do have a simple problem where you do want to run down the server and you want to do form handling, that's a pretty good way to do it.
- 25:11And there are a lot of extensions for building APIs, of which I am not going to name any of them because you can easily find them.
- 25:18I don't want to give one of them more the head of sort of an advantage over the others, which is name dropping them.
- 25:25Because I honestly have no idea which one of them is the one to pick.
- 25:29Right.
- 25:30Of course.
- 25:30When I go and I create one of these views, I basically take a method and I put a cool attribute on it like app.route.
- 25:38Is that it right?
- 25:39If I'm recalling correctly.
- 25:40Yeah.
- 25:40Yeah.
- 25:41I say app.route is the decorator.
- 25:42Then that just automatically chooses the URL template that I'm going to use, right?
- 25:47That's going to map to that method.
- 25:49Is there a way to do that with classes in a more general way?
- 25:52So I can say like map this sort of base URL to this class and then pick off the methods.
- 25:58Yeah.
- 25:58There's lots of stuff you can do that.
- 26:00I'm not a huge fan of using classes for that sort of stuff.
- 26:05So there's this class-based view thing where you can invoke different methods depending on what HTTP method, for instance, gets passed in.
- 26:15That's a thing that's a little bit more interesting than actually routing directly to methods based on a URL.
- 26:20I had not so good experience in the past with accidentally doing something you don't want to do.
- 26:27But I do think there are some packages that do that.
- 26:30But I think when it comes to this routing recursively into a class or a method in a class, there are probably systems out there for which this sort of routing behavior is a little bit more natural than it is for Flask.
- 26:45Flask has a very different philosophy for the URL mapping.
- 26:49The philosophy that originally went into the Vectsug URL system, what it's based on, is that a resource should be uniquely identified by the URL it maps to.
- 27:02Which you can actually see very...
- 27:04You can see this quite far in how the routing system behaves.
- 27:09For instance, if you go to a URL and the URL is declared with a slash in the end and you don't go to the URL with the slash, it will redirect before it even goes to matching to have the slash there.
- 27:20So it will enforce that the URL is unique if there are ambiguities.
- 27:26Even if you build a pagination system and you have slash, I don't know, slash wiki as the base part, and then you have slash wiki slash page slash one, that page slash one will redirect to slash wiki.
- 27:42So the routing system is based on the idea that everything has to be... there's only one URL for the resource.
- 27:49I really like that philosophy.
- 27:50That sounds great.
- 27:51I didn't realize it would actually disambiguate it for you.
- 27:53That's cool.
- 27:54Yeah, and that's why it's very hard to do generic URL routing with it where you have like, oh, and now I go to like a method.
- 28:01Because very often those systems, they have to be a little bit fuzzy.
- 28:05And the vector routing system is not entirely... like it's based on not being fuzzy, basically.
- 28:10So that part... that's why they are a little bit in a conflict with each other.
- 28:14But if you would want to build something like this on top of it, you could probably do it.
- 28:19But I would probably recommend looking more into Pyramid for that sort of thing.
- 28:23Sure.
- 28:24Because they have this sort of recursive routing system.
- 28:27Yeah, that makes sense.
- 28:28Okay, cool.
- 28:29So the last show that we just released on Tuesday, a couple days ago, was with Docker.
- 28:35Are you doing anything with Docker?
- 28:38Does Flask have any sort of special place with Docker?
- 28:41What's your thoughts there on how those go together?
- 28:43I love Docker.
- 28:45I think it's a cool thing.
- 28:47I don't like Docker in itself as much as I like the idea of containers.
- 28:51I think that's just an amazing thing.
- 28:55And it kind of shocks me that they haven't been more popular before because the concept is not entirely new.
- 29:02So it's great that that's taking off.
- 29:06And I don't know.
- 29:07I think this kind of sort of way of deploying applications this way is definitely going to be much more popular in the future.
- 29:14I think for Docker deployments, it's not really a framework problem.
- 29:18For Docker deployments, there's many other things that need solving.
- 29:22Like, where do I get my configuration?
- 29:24How do I make different services talk to each other?
- 29:26Right.
- 29:27How does this container talk to that container?
- 29:28Yeah.
- 29:29I don't know what the word for that is, but you have a lot of coordination between these different systems.
- 29:37And I think Flask will never gain that.
- 29:40That's just entirely out of its area.
- 29:44But maybe there will be systems that will support that in a way.
- 29:50Yeah.
- 29:51I definitely see Flask being more of one of the bricks that you use to build up that system.
- 29:55and not really involved in the connecting part.
- 29:58Yeah.
- 29:59I think this container part is going to be huge.
- 30:02But also, we are definitely going to build our applications fundamentally different when that becomes bigger.
- 30:08Many companies already do that anyways.
- 30:11It will just take some time until it trickles into the open source community.
- 30:15And we will start to pick up the ideas and lessons learned and build it into reusable systems.
- 30:23Absolutely.
- 30:24I think the whole deployment story in five years is going to look really different than it does today.
- 30:28Yeah, definitely.
- 30:29Yeah.
- 30:30Very cool.
- 30:31HTTP2 is coming along.
- 30:34What's the story of HTTP2 and Python?
- 30:36That's a good question.
- 30:38Like, you could theoretically use HTTP2 with Python.
- 30:41It would be perfectly fine.
- 30:43But you don't gain any of the benefits you have from that.
- 30:46And in order to actually use HTTP2 with Python or with an application efficiently,
- 30:53I think we will all have to actually sit down together as a community again and figure out how to extend the Whiskey protocol.
- 31:00So there are two ways we can go.
- 31:02Either one of them is nobody cares about WSGI anymore as a protocol and it's useless and it will just slowly die and we will bypass it and just figure out how to make frameworks talk directly HTTP, which might happen.
- 31:19HTTP2 as a protocol is complicated, but it's a little bit more lightweight in a way than HTTP is maybe.
- 31:28It's tricky.
- 31:29But basically the point is, Whiskey could die and we no longer care about it.
- 31:33Or we will have to evolve Whiskey to support what HTTP2 supports.
- 31:38Because one of the big features that you have as HTTP2 is that the server can decide to already deliver some content into the client's buffer before the client has to actually ask for it.
- 31:50So you could send your current page plus all the images plus all the statuses plus all the JavaScript in one go with the client having to do individual requests.
- 31:58And we don't have a good support for any of that stuff in Python so far.
- 32:04Right, exactly.
- 32:06Because those are going to different routes and it's basically coming in.
- 32:09Yeah, you have to restructure your application for that.
- 32:11It's very hard to just pretend that you don't have to have an understanding of that.
- 32:16You as an application writer have to inform the server about related resources.
- 32:23And there is no good way to magically do that.
- 32:26I mean, it could probably work, but yeah, we don't have that.
- 32:29And we might have to architect our applications a little bit different for that.
- 32:33There's a lot of promise there to reducing the number of actual server requests to load a page from something like 15 to 2 or something like that.
- 32:42That would be really nice.
- 32:42And we've got to make it possible, right?
- 32:44Okay, so very interesting.
- 32:46What's the future of Flask?
- 32:49Where are you putting your energy into when you're working on it now?
- 32:53I'm barely working on any of my open source libraries in the last two years, to be honest.
- 32:59I make sure that they release.
- 33:02I make sure that patches get merged at least to some degree.
- 33:07But there are many more people than me now which take care of those things.
- 33:11Yeah, looking on GitHub right now, you've got 268 registered contributors to Flask.
- 33:17So it's almost a management job, huh?
- 33:19Yeah, it becomes different than it was originally.
- 33:24For me, personally, what's in the future of Flask for me is that it becomes more stable.
- 33:30I don't want it to change too much.
- 33:33I learned this lesson in a way with Jinja.
- 33:36Jinja is a tablet engine which hasn't changed functionality-wise in a really long time.
- 33:42And I know there are flaws in there, and I know there are things I would do different nowadays.
- 33:48But I don't want to break anyone's stuff to fix some problems that I made.
- 33:54Because usually, it's not that you can fix a problem and it will make everyone's life easier.
- 34:00Usually, if you make a design this mistake, you have to change it in a way where you break people's stuff.
- 34:06And that makes nobody happy, especially if the problems are not big enough.
- 34:09Flask will not evolve in such big ways as Django as a framework is evolving.
- 34:17I think it's more likely that if I discover that I will no longer like developing this Flask,
- 34:22there will be a separate project which will solve the problem in a different way and become that.
- 34:29Flask doesn't really have to evolve in itself.
- 34:32I think it's not the worst spot right now.
- 34:37It needs new releases.
- 34:38It needs updates.
- 34:40But I don't think it has to fundamentally change to stay relevant.
- 34:44Sure.
- 34:44I think that that's probably partly attributable to the fact that you kept it small and didn't try to make everybody build on your APIs, but kind of pass through.
- 34:53Yeah, I think keeping it small is a good thing.
- 34:55I'm struggling right now to keep another library of mine small, which is Click.
- 34:59Yeah.
- 35:00Well, Click's cool.
- 35:02Can you tell people what Click is?
- 35:03Click is basically a micro framework for making commands and applications.
- 35:10It's based on similar ideas as Flask in a way.
- 35:12It's very composable.
- 35:13You make a Click application and you can attach another Click application to another Click application.
- 35:21You can basically build your whole whatever you used, art parse or opt parse or whatever else you had before for little command line scripts.
- 35:29You can use Click for that and then you can just scale them up to larger applications over time.
- 35:35So it's very often in the past I used to do this little script which just did one job and it was really terrible.
- 35:42And then if I wanted to make it nicer by adding a command line interface, I really hated the experience of adding yet another arc parse invocation for this.
- 35:53Or even things like DocOpt suffer a little bit from the same thing where it's just too much work to deal with the argument parsing properly.
- 36:01So this is where Click comes in handy.
- 36:03You basically make a Click application, attach a function to it and describe the parameters that go in.
- 36:10And then you have a little script.
- 36:12And then if you want to merge multiple of those scripts together, similar to how systems like Django Manage have like 20,000 subcommands.
- 36:21You could take all of those scripts and then merge them together into a larger application.
- 36:26And they will still continue working as they did before.
- 36:28It's a very composable way to build command line interfaces.
- 36:31That's really amazing.
- 36:32So it sounds like they'd be easier to maintain because they're not this great giant thing in the end.
- 36:36They're like little parts that are focused on one task.
- 36:38Yeah.
- 36:39And I think it's a lot more fun to keep them that way.
- 36:43What's the story with Python 3 and Flask?
- 36:47I don't know.
- 36:50The thing is, it runs on Python 3.
- 36:54That's as far as my support for it goes.
- 36:56I will try to keep it working on Python 3.
- 36:58I'm not using Python 3 myself.
- 37:00So that's basically it.
- 37:03If people would start using Python 3, then I will move over there as well.
- 37:06But since nobody else is moving, I am not really moving.
- 37:08It's a very pragmatic approach.
- 37:12But I have more important things to do than try to force people to go to some version of the language.
- 37:20Sure.
- 37:21Basically, that's what it boils down to.
- 37:23There are plenty of comments of mine on the interwebs in regards to the state of Python 3.
- 37:31There is really not much else to add to that.
- 37:34Sure.
- 37:35And I don't necessarily want to make the whole show about that.
- 37:37So that's all good.
- 37:38But what do you think the future of Python is?
- 37:41Like where are things going more broadly?
- 37:43I don't know.
- 37:45So there's always like what's the future of a programming language?
- 37:50And then what's the future of what I will be doing?
- 37:51I don't know what the future of Python is as a programming language.
- 37:54That it will do something.
- 37:59For me personally, the sort of development I've been doing more and more in the last couple of years makes me feel like I probably want to start picking up other technologies as well.
- 38:11I started writing a lot more JavaScript, even though I don't like the experience.
- 38:16I started writing a ton of Rust.
- 38:18I picked up a little bit of Golang just for fun.
- 38:22And then I'm starting to write a lot more C and C++ as well.
- 38:25So by share of how much time I spend on one programming language, Python is still above 50%, but it's dropping.
- 38:32And that is probably for me personally that I will start to look at other things as well.
- 38:37Python will always be there for the things I have been doing with it in the past.
- 38:42But I might just be doing different things in the future.
- 38:44Yeah, that makes sense.
- 38:46I think if you look at the types of technologies that have been used and what's popular and what's not and so on.
- 38:52And in the last couple of years, there have been so many, maybe the last five years, so many new technologies.
- 38:58It used to be like, well, are you a C++ or a Java or a .NET or Python guy?
- 39:04And there was like a few choices, right?
- 39:06And now it's a hundred types of frameworks in JavaScript.
- 39:10And there's so many variations.
- 39:13I think there's one thing that's happening, which is that people used to associate programmers with a programming language really strongly.
- 39:21And now if you look at some of those people that used to be associated with one programming language, they're actually doing different things.
- 39:27Like, for instance, a good example is the packaging infrastructure in the Rust programming language is written by Ruby people.
- 39:35And not just any Ruby people, but the ones who wrote Bundler, which is one of, if not the most popular way to do, to basically work with gems in Ruby.
- 39:47So you have this sort of situation where people just jump from community to community.
- 39:53Ian Bicking, who was the heart and soul of web development and Python, moved over and started doing JavaScript.
- 40:02So it's, and then you have people from JavaScript who moved to Python or who moved to even C# or something.
- 40:09So it's not that people stay very strong in one community.
- 40:13They don't leave it, but they might just also start using other technologies.
- 40:18And I think that's more common now.
- 40:20Yeah, and I think it's probably healthy, right?
- 40:22You get exposed to a lot more that way.
- 40:24Cool.
- 40:25Before we move off Flask, what are the notable deployments Flask like?
- 40:29Do you know popular websites running it or things like this?
- 40:32I don't know.
- 40:34I used to keep this powered by Flask page running.
- 40:37But fundamentally, one problem you have with Flask is people will start using it at one point.
- 40:44And then if you look at the same website after one and a half years, it has either disappeared because the website was of a startup was not a good business idea or something.
- 40:53Or it would grow and become larger.
- 40:56And then all of a sudden, it will outgrow what it had and might change technology.
- 41:01So I don't know.
- 41:03I don't keep track of what currently runs Flask or not.
- 41:06I know that Discuss was using it heavily.
- 41:09I think they still are, but I think they're using some Go.
- 41:13Yeah, so it's very hard to say what website is based on what technology at this point, especially for a framework.
- 41:20Because it's a small part in the overall execution of the whole thing.
- 41:25So I don't know what currently runs on Flask.
- 41:28I know there are plenty of websites which do use it.
- 41:31Yeah, if you have 14,000 stars on GitHub, there's definitely a lot of people using it.
- 41:34So it's just not clear what they are, right?
- 41:36They're dark matter websites.
- 41:39Nice.
- 41:41So one of the other things that you brought up was Rust.
- 41:44Is that a language that Mozilla came up with?
- 41:46It's not Mozilla came up with, but Mozilla started supporting the development heavily.
- 41:53Okay.
- 41:53So what is Rust?
- 41:55Rust is definitely not Python.
- 41:56It's a completely different language.
- 41:58It's more C++ than it is Python.
- 42:01It's a really weird language in what it tries to do.
- 42:06And I find it interesting because it's the first time that someone came up with a really crazy idea of how to build something.
- 42:15And it actually turned out practical enough that it might start sort of a new way of thinking of how to do programming.
- 42:23That's really awesome.
- 42:24It's a system-level language, right?
- 42:27It's basically a system-level language.
- 42:29By system-level language, it means a language that gives you low-level access to the operating system, nearly as C or C++ do.
- 42:38Or the same way C and C++ do.
- 42:41But unlike C and C++, Rust doesn't crash on you.
- 42:44It doesn't feel like you have to juggle with pointers or anything of that sort.
- 42:48It feels very much like you're programming in something very high-level, like Python or C#.
- 42:55Something that is very friendly to you as a developer.
- 42:58But it has manual memory management in the sense that there is no garbage collector.
- 43:02There is no reference counting.
- 43:04It achieves this...
- 43:07I would say this...
- 43:09I don't know what it achieves.
- 43:10Basically, it achieves the way of development.
- 43:13It is very high-level.
- 43:15But also, at the same time, very close to the hardware by tracking who owns what piece of memory at what point in time.
- 43:25And it's a very interesting way to develop because it makes you think a little bit more about what you're doing.
- 43:29And it also rules out a ton of problems in the process.
- 43:33It makes you a better developer just because it tells you to rethink things that you could otherwise do in programming languages, which were a terrible idea.
- 43:42I had an example a couple of days ago where I was showing how threading issues in Python are something that can just happen.
- 43:54Or they will naturally happen because there's nothing in the language that prevents you from doing something really stupid.
- 43:59Like not mutex locking some important piece of code.
- 44:05And Rust is different because this concept of memory ownership helps really greatly when you build anything concurrent.
- 44:13So it's a very interesting language for that reason.
- 44:17I find it exciting because there's never been anything like this before.
- 44:21There were languages like Java, Go, which have garbage collector and achieve safety this way.
- 44:27And there have been languages like C and Z++, which have been very fast, but also very frustrating if you did something wrong.
- 44:34And just generally not very fun to work with.
- 44:37And Rust just is very different in that sense.
- 44:41That's really cool.
- 44:41It sounds inspiring like I should check it out.
- 44:44What kind of things do I build with Rust?
- 44:46Well, the thing is, Rust just came out 1.0 finally a couple of days ago.
- 44:50So at the moment, you probably can build less stuff with this than with many other languages just because it's very new.
- 44:57But there's already a handful of stuff you can build really well with Rust.
- 45:01If you're in the computer games, there's a ton of really good libraries that you can use to build your own game engines and just your own games.
- 45:10It has excellent support for doing basic game mathematics operations, talking to your graphics card, getting input from joysticks and game pads and just keyboard and mouse.
- 45:21So that's a very strong area.
- 45:23And that's just natural to the language because that's why it's very strong.
- 45:27But it also already has really good support for doing web applications.
- 45:32The database drivers, you can talk to Redis, you can talk, I think, to MongoDB.
- 45:36There's a couple of web frameworks for it.
- 45:40They all feel very different than frameworks do in Python just because it's more rigid.
- 45:46But if you're into writing JavaScript applications with a backend API, you can do that quite well in Rust already.
- 45:55In fact, what the Python package index for Rust is, it's called crates.io.
- 46:00That is entirely written in Rust itself.
- 46:03And you can get the source code.
- 46:05You said crates, like C-R-A-T-E-S?
- 46:07Okay, cool.
- 46:08How many packages are there?
- 46:113,000, I think.
- 46:14I don't know, actually.
- 46:14Yeah, we got 2,200 already.
- 46:17So it sounds like it's growing fast.
- 46:18That's awesome.
- 46:20Yeah, it's doing really well.
- 46:21So it doesn't have 3,000 yet.
- 46:22But it is growing.
- 46:23And it has...
- 46:25Because it is a new programming language, many of the problems that we still fight with in the Python community in getting our infrastructure improved, Rust never had as a problem.
- 46:36Like, for instance, the packaging in Rust is really good.
- 46:41It is a perfect package manager that comes with the system, which makes development a ton of fun.
- 46:47It's similar to how the JavaScript community had npm quite early on.
- 46:51We have with the combination of pip and VirtualLine and everything.
- 46:55But for those systems, it just already becomes as a base package, basically.
- 47:02It's really cool that basically that came out with it as it...
- 47:05You know, from day one, that was there, right?
- 47:08That's nice.
- 47:08Yeah.
- 47:10So Cargo came...
- 47:11Well, it wasn't day one, because if you consider Rust is already a couple of years old by now because it had a long development path.
- 47:18But Rust 1.0, so the official release, comes with package manager and linters and documentation tool and everything.
- 47:24Yeah, really nice.
- 47:26Okay, so I'm definitely going to check out Rust.
- 47:28That sounds neat.
- 47:28Armin, I think that might be a good place to wrap up the show.
- 47:33Before we finish, though, I'd like to ask you a question I always ask my guests,
- 47:38which is, what's your favorite PyPI package?
- 47:41Or what are some notable ones that you would like to call people's attention to?
- 47:45Like, say, hey, this is awesome.
- 47:46Check it out.
- 47:46Oh, that's hard.
- 47:49Well, I can't name any of my own ones, obviously.
- 47:51I'll name them for you.
- 47:52So Flask, Click, and...
- 47:54It's probably SQLAlchemy.
- 47:56It's my favorite package.
- 47:58It ends up almost everywhere.
- 48:00And it's just really good.
- 48:01So that will have to be it.
- 48:03Yeah, SQLAlchemy really is amazing.
- 48:06And we had Mike on for show five, I think.
- 48:08Yeah, SQLAlchemy is amazing.
- 48:09Cool.
- 48:10And what editor are you using these days for your Python stuff?
- 48:13I'm still using Vim.
- 48:14I'm trying to migrate over to a new Vim.
- 48:17So that might happen soon.
- 48:19But so far, it's Vim.
- 48:20All right.
- 48:21Awesome.
- 48:22Armin, thank you for being on the show.
- 48:24It's been a great conversation.
- 48:26You're welcome.
- 48:26It was fun.
- 48:27Yeah.
- 48:28See you later.
- 48:29This has been another episode of Talk Python To Me.
- 48:34Today's guest was Armin Roenaker.
- 48:36And this episode has been sponsored by CodeChip and Hired.
- 48:40Thank you guys for supporting the show.
- 48:42Check out CodeChip at CodeChip.com
- 48:45and thank them on Twitter via at CodeChip.
- 48:47Don't forget the discount code for listeners.
- 48:49It's easy.
- 48:50Talk Python, all caps, no spaces.
- 48:52Hired wants to help you find your next big thing.
- 48:56Visit Hired.com slash Talk Python To Me
- 48:58to get five or more offers with salary and equity right up front
- 49:02and a special listener signing bonus of $4,000.
- 49:06Also, don't forget, an awesome t-shirt awaits you at bit.ly slash PythonShirt
- 49:12or just visit our website and click on shirt in the footer.
- 49:16You can find the links of the show at Talk Python To Me.com
- 49:20slash episodes slash show slash 13.
- 49:24Be sure to subscribe to the show.
- 49:26Open your favorite podcatcher and search for Python.
- 49:28We should be right at the top.
- 49:29You can also find the iTunes and direct RSS feeds in the footer of the website.
- 49:34This is your host, Michael Kennedy.
- 49:36Thanks for listening.
- 49:37Smix, take us out of here.
- 49:40Staying with my voice.
- 49:41Staying with my voice.
- 49:41There's no norm that I can feel within.
- 49:43Haven't been sleeping.
- 49:44I've been using lots of rest.
- 49:46I'll pass the mic back to who rocked it best.
- 49:49I'll pass the mic.