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