Learn Python with Talk Python's 270 hours of courses

#182: Picture Python at Shutterfly Transcript

Recorded on Thursday, Oct 4, 2018.

00:00 Join Doug Farrell and me as we discuss his career and what he's up to at Shutterfly.

00:04 You'll learn about the Python stack he's using to work with not just bits and bytes,

00:09 but physical devices on a production line for creating all sorts of picturesque items.

00:14 You'll also hear how both he and I feel it's a great time to be a developer,

00:18 even if you're on the older side of, say, 30, 40, or beyond.

00:21 This is Talk Python to Me, episode 182, recorded October 4th, 2018.

00:27 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. Follow me on Twitter where I'm @mkennedy.

00:50 Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.

00:57 This episode is brought to you by LogRocket and Rollbar.

01:00 Please check out what they're offering during their segments. It really helps support the show.

01:04 Doug, welcome to Talk Python.

01:06 Thank you very much, Michael. I'm glad to be here.

01:07 Yeah, I'm glad to have you here. It's great.

01:09 We've been interacting on email and on social media and stuff.

01:13 I've talked about some of the articles you've written before, and you've sent in recommendations and various things for us.

01:18 So it's nice to finally have you here.

01:20 Yeah, I'd like to drop notes to you and Brian on the Python Bytes podcast about articles that I've written in RealPython, the site.

01:29 Yeah, there are definitely some good ones.

01:30 And I want to dig into some of those, actually, as we get further into the show.

01:33 But let's start with your story about how you got into programming in Python.

01:37 Well, I actually got started pretty late.

01:39 I was probably in my late 20s by the time I got into programming back in the early 80s, late 70s, early 80s.

01:47 I had failed at Fortran years before the first time I went to college, mostly because, you know, back then it was all punch cards and having to go down to the dungeon to hand it over to somebody who would tell you three days later whether your program worked.

02:02 I didn't really get excited about it until it was either.

02:04 Yeah, I could see how you wouldn't be so excited about that.

02:06 That's not the same as, you know, fun GUI editors and compilers and Stack Overflow and all that stuff, right?

02:13 It's a different world.

02:14 Well, plus, you know, I saw lots of people who actually left the program, but they'd come down the stairs with a giant stack of COBOL cards, drop it.

02:21 The whole thing would be spread all over the place, and they'd leave the program crying, you know, because they just couldn't stand to sort them again.

02:27 They just lost their will to be part of that anymore.

02:31 That's it.

02:32 They'd moved on to something else.

02:33 So I got excited about it when I bought my first personal computer, which was back then I bought a Radio Shack color computer and taught myself some basic and a little bit of 6809 assembly language for some, you know, because as most young guys, I was thinking I was going to be a game programmer.

02:49 How interesting.

02:50 You know, you think of, like, getting started programming.

02:52 People say, well, Michael, programming's kind of hard.

02:55 I have a hard time wrapping my mind around, like, Python or JavaScript.

02:58 Like, starting with a similar.

03:00 Like, that is starting.

03:00 Seriously.

03:01 I still can't do similar.

03:03 The color computer was so slow.

03:05 It was less than a megahertz clock speed.

03:07 So to do anything fast, you had to really get down and dirty.

03:09 Yeah.

03:10 But, okay, so you started there.

03:11 So that gives you a good foundation of it's only going to get easier from here.

03:15 Right, yeah.

03:15 And I had my – actually, I was back in school by then going after my physics degree, BS in physics.

03:22 And my senior project was building a fairly primitive CAT scan device with some high-precision translation tables and using Pascal on this wacky computer called a Terrax.

03:34 And that really – I really enjoyed that.

03:37 I spent most of my time doing that besides failing French.

03:40 And that gave me enough buzzwords to get my first engineering job as a process control engineer doing automation systems for municipal water systems and gas pipelines.

03:50 Wow, that sounds interesting.

03:52 So that's a lot of, like, controlling hardware, right?

03:55 Right, yeah.

03:55 Which is kind of a theme, it sounds like, from all the stuff that you've been doing.

03:58 Yeah, it was kind of a big scale, you know, like a macro version of hardware control where you're doing really huge systems.

04:05 I think the biggest thing I did was I automated a 35-gallon-a-day, 35-million-gallon-a-day clean water system in Arizona.

04:14 I think about – there were certain steps in my programming career that they were sort of, you know, take-your-breath-away moments.

04:23 And I remember the first time I wrote – this is for some other company – I wrote my first e-commerce system, and it was doing, like, $4,000 transactions per transaction.

04:34 I was like, wow, I had really better not mess this up.

04:38 You know, if we do this wrong on scale, it's going to be a problem.

04:40 Did you have that feeling when you were working on that much water and that much hardware?

04:45 Yeah, because the scale of this thing is huge.

04:47 I mean, this was early in its construction, so we were actually – when I was out there, I was actually myself and the other guy we were working with.

04:53 We were able to ride our bikes inside of the 35-million-gallon tank because it wasn't in use yet.

04:59 You had your own velodrome.

05:00 Yeah.

05:02 And we had one disaster, thank God it wasn't me, where we had a flood where we managed to wash away a golf course putting green down the road.

05:11 Hopefully no one was putting at the time.

05:13 Well, it was late at night, and we heard – the course manager was over screaming at us, and then it turned out to be not us.

05:21 So that was a nice escape.

05:23 Well, that's really good.

05:25 That's really good.

05:25 So what languages were you using to do all this?

05:27 This was a proprietary language that the company had written.

05:31 It was a software simulation of hardware.

05:34 So when you do hardware control, there would be things like timers and PID controllers and digital switches and analog inputs and outputs, comparators, all these hardware things that you could wire together.

05:48 And this simulated those.

05:50 And in that language, the variables – you could think of the variables as wires.

05:55 So anything you connected a variable to was like wiring those two things together.

05:59 So you could string all these things like an analog input to a comparator to a set point control to a PID loop to an analog output that would control a valve that would keep a tank from overfilling or underfilling.

06:12 Yeah, that's really interesting.

06:13 Do you see as much of those sort of custom programming languages now?

06:18 Or do you see people adopting things like Python and JavaScript and other languages for that purpose?

06:24 Well, I know that that company is still big in the game and they're still around.

06:29 And I think my experience with municipalities and gas pipeline companies is that they're very reluctant to change.

06:37 They're always going to stick with something that works.

06:39 I don't know if you've ever worked with PLC controllers, programmable logic ladder controllers.

06:44 Yeah, I only have heard the term.

06:45 Those are very popular because they work and people know them.

06:50 So the same thing applies to municipalities.

06:52 It works and they know them.

06:53 I mean one of my experiences when I was there was having a realization that they had our computer stuff in the same depreciation column in their spreadsheet as manhole covers.

07:07 So they expected our computer stuff to last like 50 years like a manhole cover.

07:11 And I was like, really?

07:12 I don't think so.

07:13 This is not going to work out the way you think this is going to work out.

07:18 So that was nice.

07:20 Yeah.

07:21 They were like, well, how are we going to get parts to replace this?

07:24 I'm like, no, you're going to replace the whole thing in about 20 years, I think.

07:26 Maybe even less.

07:27 Yeah, how interesting.

07:28 You moved on from there, right?

07:30 Towards the web?

07:31 Yeah, after I left that company, I worked at a high-speed pick-and-place machine.

07:37 It was kind of a robot that assembled electronics boards by picking up chips, flying them over a camera, put them on the board.

07:43 And about, I don't know, the fast one was like 20,000 parts an hour, which is really moving.

07:49 And that was my really— Kind of stay away from it, right?

07:52 Don't get too close to it, huh?

07:53 Yeah, there was lots of stuff about don't open the door when it's moving because you could get really hurt.

07:59 And we were kind of—that wasn't—I went to a trade show, and they really had some fast and big machines like that that would scare you to death.

08:06 Yeah, I can imagine.

08:07 But that was sort of like my low-level embedded programming, which I really enjoyed.

08:10 And eventually, I went to work for a company that did—where my internet exposure came in, where they were trying to put reference titles like encyclopedias online.

08:20 And now I worked at Shutterfly.

08:22 This is probably pre-Wikipedia, right?

08:25 Yeah, this was back in the Encarta days and Griller's Encyclopedia Online.

08:31 And I actually worked on the CD-ROM version of that and then the web version.

08:35 Yeah, cool.

08:36 Yeah, and now you're at Shutterfly, and it sounds like a really interesting place to be.

08:41 And it also sounds like you're getting to do some of this sort of software meets hardware thing.

08:45 Yeah, it's satisfying.

08:46 I really like that part where software meets the real world.

08:48 It's not just all a bunch of bits moving around in the computer.

08:51 It has enough of the things that I write.

08:54 Everything I write is all on our production floor, not customer-facing.

08:57 So it allows our production people to interact with the presses and other machinery that actually produces books.

09:05 Shutterfly is a digital book publisher where customers can upload their photos and get all kinds of products.

09:11 Like photo books you can send out for gifts or printed stuff or printed photos out of your digital photos, things like that.

09:18 Pillows and coffee mugs and desk frames and all kinds of big canvas prints, which are all interesting products.

09:25 Our motto at Shutterfly is sharing life's joy.

09:29 So it's an interesting way to think about photos and how there's so many digital photos.

09:35 And then people get so many and they get overwhelmed about what am I going to do with this thing, this pile of pictures.

09:40 You know, I just did that.

09:41 I ordered a photo book for my family because we have like 30,000 photos.

09:45 And I'm like, we're not going to go through these.

09:47 There's just – it's overwhelming.

09:48 But if I could put it on the coffee table and friends come to visit, like we can experience them in a different way.

09:53 It's pretty cool.

09:54 Yeah.

09:54 It makes great gifts.

09:55 I mean, you know, grandparents.

09:56 I know my daughter sends me books that she makes with our product.

10:01 And I love that stuff.

10:03 Hey, you printed this for me.

10:05 You just don't know it.

10:05 Yeah.

10:06 Usually, hopefully, I don't find out that I printed it and made it wrong.

10:10 That's right.

10:11 This is messed up.

10:12 Oh, I remember that, Bob.

10:13 Yeah.

10:13 Oh, sorry.

10:14 Yeah.

10:14 So that's – doing that stuff satisfies my kind of need to have the computer touch the real world because we interact with the presses and hardware directly or more – a little directly.

10:25 Yeah.

10:26 It's not as dangerous as like high-speed stuff where people could get hurt.

10:29 Yeah.

10:30 You don't want to be putting people onto a board.

10:32 No.

10:33 Yeah.

10:34 This sounds like really fun.

10:35 And it's that software meets hardware thing.

10:37 And you guys use a lot of Python at Shutterfly, right?

10:40 Yeah.

10:41 They actually – they acquired the company I was working for and we were doing all Python stuff.

10:45 We were one of their smaller competitors and they acquired us.

10:48 And I came on board as a full-time Shutterfly employee, which was great.

10:52 And that was their first exposure to Python.

10:56 They had been a traditionally and still are a big Java shop.

11:00 A lot of the work that they had done and a lot of their infrastructure is in Java.

11:04 But through acquisitions, they've become a heterogeneous tech stack company because they have Java, Python, PHP, mobile app development languages, JavaScript, of course, all over the place.

11:16 Yeah, of course.

11:17 But having us come on board, one of the things that happened right away was that we were able to take over a section of gifting products because Shutterfly has a huge – they do a huge amount of book printing, of course.

11:31 But the gifting products are becoming – is a fast-growing market for them.

11:36 And my group that I'm in was able to implement a lot of the gifting products and is continuing to implement new gifting products all the time in Python.

11:44 And almost that whole – almost the whole stack for that production is in Python.

11:49 That's really cool.

11:50 Do you guys see the agility and the ability to, you know, pip install anti-gravity to – as a real advantage for your team?

11:59 Maybe even within the company, people go, oh, yeah, we know those guys can deliver quick.

12:03 Yeah, that's a – there's two parts of that is that we can be extremely agile.

12:08 And we first – when we first did our first pass at producing gifts products, I think it was – I think it was a real eye-opener for people to see how quickly we could actually bring a product to bear into production.

12:20 And then not only get it there to where they could start producing it, but iterate quickly to improve the process because, you know, the first pass would always have issues or they'd want changes.

12:30 And the ability for us to iterate very quickly I think is a huge benefit for not only us but also the company in general.

12:38 Yeah.

12:38 Yeah, there's an interesting story about how Google acquired YouTube and they had Google Video and a bunch of C++ guys trying to compete with them.

12:45 And YouTube was a little upstart built on Python and they were just out, you know, outperforming and adding features.

12:52 Maybe they needed more servers or something to make it go, but it didn't matter, right?

12:56 So kind of like you, Google – or like Shutterfly, Google solved the problem by buying YouTube and that fixed it.

13:03 Yeah, and it's – you know, we've been growing because they continue to – you know, they continue to sort of give us the opportunity to add new products, sort of subsume some of our products into our – the way we work in Python.

13:16 And it's – we're doing a lot of infrastructure work.

13:19 Any growing company has to do a ton of infrastructure work all the time.

13:23 And we're doing a lot of that infrastructure work and architecting based on the experience that we've had with Python and some of the tools that we use and interface with using Python.

13:31 And like you said, the pip install thing, we have our own PyPy server.

13:35 Oh, nice.

13:36 With modules that we have figured out are safe and to use and build against.

13:41 But because we have our own, we have a sort of a vetting process to see new ones that we can add because, well, I know for myself, I'm always like, hey, there's a cool module.

13:48 I'm twisting people's arms to get it into our server so I have access to it.

13:52 That's really cool.

13:53 So what technology are you using for your private PyPy server?

13:56 Well, we have just a copy of the PyPy server code.

13:59 It doesn't have the whole front end, but it just has the back end where you can just do a pip install.

14:04 So long as you point at that server with a pip config file.

14:08 Right.

14:08 So you can configure – It will just grab files.

14:10 Yeah, you can configure your user profile.

14:11 So if you say pip install, it first looks there, right?

14:14 Yep.

14:14 That's pretty cool.

14:14 My own development.

14:15 We're moving from server-side development to client-side where we're using containers, Docker containers.

14:22 And for that stuff, it's much – we often – this is how stuff gets started.

14:27 We'll often grab a module from the regular, the public PyPy server, PyPI server.

14:33 And then that – once you see some success in that and people start to review your code, that module will get vetted and checked out and moved into our private PyPy server.

14:42 Yeah.

14:42 Nothing is a more convincing argument than success.

14:45 I know.

14:46 I've been in so many places where people debate, oh, if we do it this way, it'll be better.

14:50 No, that way, it'll be better.

14:51 Like, you know what?

14:51 We're just going to build – like, I just built it this way.

14:53 I know you said it can't work, but here it is working.

14:55 Can we discuss whether or not it's still working?

14:58 Yeah.

14:58 Okay, fine, it's working.

14:59 Yeah, you're right.

14:59 That would work.

15:00 Delivery often wins.

15:01 Let's do that.

15:01 Being able to deliver wins.

15:02 Yeah, it certainly does.

15:03 This portion of Talk Python to Me is brought to you by LogRocket.

15:09 LogRocket will help you view errors in activity from your user's perspective.

15:13 Did they tell you they couldn't log in?

15:15 Well, with LogRocket, you'll get a session where you can see a pixel-perfect replay of what your user saw at that moment.

15:21 The ability to inspect the state of the application at any point in time.

15:26 You'll view every network request and response on their session, as well as a console log of all the JavaScript messages and errors.

15:33 And it goes beyond just errors.

15:35 You'll learn where your users are getting stuck.

15:37 LogRocket intelligently surfaces the key moments of user frustration showing you how to improve your site.

15:43 And LogRocket works with your stack regardless of the language or framework you're using.

15:46 And they even provide SDKs for popular front-end technologies like Vue.js, React.js, and more.

15:51 Do you already use systems such as Rollbar?

15:54 Well, you're in luck because they integrate seamlessly with Rollbar and others for great visibility of front-end and back-end errors.

16:00 Understand the cause of every bug and customer issue today.

16:03 Visit talkpython.fm/LogRocket to get started with their free tier.

16:09 Let's look a little bit inside at what you guys are working with, some of the libraries and stuff.

16:14 I think it's interesting for people in different industries or not in companies like Shutterfly to just see what kind of apps you're building.

16:22 So could you give us just a quick flyover of some of the tools you're using?

16:25 A lot of the stuff I build directly that I guess I consider myself a full-stack developer at Shutterfly where I build the back-end server and I also do the front-end code in JavaScript to build web applications.

16:39 I've been doing a lot of that with just plain jQuery, but I'm slowly moving to React for my front-end framework.

16:45 But for the back-end, I prefer to use Python Flask with gevent and SQLAlchemy as the database interface.

16:54 And we try to make our stuff as asynchronous as possible because we have a lot of users, not only users, but we also have a lot of processes that communicate together.

17:03 We also use a message bus system as our interconnection between processes.

17:10 So rather than like we're rapidly getting to a point where we're decoupling from database access directly to using a message bus to talk to a data service.

17:20 So all of the database access is sort of hidden away.

17:24 There used to be a lot of like per max, not good, and we're moving away from that.

17:31 And then we use like we use RabbitMQ as a database as a message system.

17:36 We do a lot of – on the back-end, besides the like full-stack stuff that I do, there's a lot of processes that we run in Python.

17:42 So we have a lot of twisted code.

17:44 We use twisted code for asynchronous work.

17:47 We also use a lot of gevent for the same thing.

17:49 I know I'm more comfortable with gevent than I am with twisted, although I've written quite a bit of twisted code so that we can handle multiple – we don't do so much networking code as much as just there's multiple things in motion that take time.

18:03 Like as in a production environment where stuff is getting printed and cut and bound and shipped, all those events, they're separated by time.

18:14 So asynchronous code is really handy for that.

18:16 So you can set something.

18:16 You can set a state and then you get a call back, you know, who knows, 5, 10, 20, an hour later that it's actually finished or moved on to another state.

18:24 So to be able to handle essentially thousands and thousands of those state-driven processes is really handy.

18:33 That's really cool because if you tried to just wait for that response, that would be a problem.

18:39 Oh, yeah.

18:39 If you wait for an hour, this Flask server just won't scale.

18:45 You know, I mean, we set the time on it.

18:46 I'd have a bunch of production lead guys in my office stamping their feet in a heartbeat if that was the case.

18:51 How interesting.

18:52 When you talk about doing asynchronous stuff with Flask, is that using, say, gevent on Flask?

18:58 Or are you doing, like, architecture that has queues?

19:02 Well, we have a couple things.

19:04 I use gevent in Flask to try to make that as – add asynchronous behavior to that.

19:10 It's still – because of the database access, it still can get paused on a database call.

19:15 That's one of the reasons why we are moving to – the data access is going to another process.

19:21 So that other process now becomes – you know, it's handled – there's multiples of those.

19:26 And it handles the database.

19:28 But my call from my application or any other application can be asynchronous to that.

19:33 It's no longer waiting because it's – now it's going to get a call back when it's done.

19:36 Yeah, that's really cool.

19:37 And it just queues up on that other system probably.

19:40 It won't time out, for example, and things like that, right?

19:43 Yeah, those other systems are all also entirely asynchronous.

19:46 So it has a big queue of things that are ongoing and it's working on and, you know, it'll get back to you when they're done.

19:50 And those come across the message bus as an event.

19:54 I think it's so interesting to look at the different types of architecture choices people make based on, you know, what you're trying to do, right?

20:01 You're here working with latencies in the minutes or hours.

20:05 So you might choose a really different architecture, whereas people say, well, the database is kind of slow.

20:11 It takes 30 milliseconds to get back to us and we want to go scaling.

20:13 30 milliseconds, I laugh at that.

20:15 I'll just use an – it'd be like an ASICIO event loop or something like that.

20:21 That would be fine for that, right?

20:23 So quite interesting to think about.

20:26 So that's the backend stuff.

20:27 I guess one thing I did want to ask you about when you talked about G-Event and Flask and all that, and I don't know that this would – I don't think that this would really necessarily be the right application for it.

20:37 But have you looked at Quart?

20:39 I have, and I've been following the ASIC stuff like SANIC and Quart, and I'm trying to get up to speed on the Python 3.7, the ASICIO, and ASIC Await stuff because in many ways, I'm moving away from really needing Flask.

20:53 I mean it just – it provides a lot of features that I don't use.

20:56 Like I don't do any web form validation.

20:58 I'm doing all either WebSocket or AJAX calls, REST APIs.

21:05 So I don't do a lot of form validation.

21:06 I don't serve a lot of files.

21:08 I'm mostly creating REST APIs.

21:11 So I just want to make that part faster, and those things that you mentioned would do that.

21:18 So I'm looking into that to take better advantage of the system.

21:21 Yeah, that makes a lot of sense.

21:23 And there is a lot of stuff in these web frameworks that you just don't need if the response is Flask.jsonify.

21:29 For my case, I don't even serve up the web pages, the front end anymore myself.

21:34 That's done by a dedicated web server.

21:36 So my application is strictly – has turned into a REST API.

21:42 That's a really interesting place for people to work who want to work on the web, but they are not designers.

21:48 Yeah.

21:49 Right?

21:49 They don't want to try to do all the CSS and layout and make it pretty and put the hero banner on there and all that stuff.

21:56 There's still some really interesting and challenging programming to be done building this back-end layer, I think.

22:02 Yeah, I absolutely agree.

22:03 I am currently working on this gigantic project, which is this REST API that drives a big part of our business.

22:11 And I find that part – it's challenging because I'm always negotiating with the front-end guys about what the payload looks like and what the back-and-forth looks like.

22:20 I also enjoy the front-end because that gives me – then I'm arguing with myself about what's the best way to get this data across.

22:26 But also, I really enjoy the GUI part.

22:29 I used to be a – for a short time, I was a Windows developer.

22:33 And I like that user interaction and trying to figure out what's the best way to present this activity to make my user's life easier.

22:41 And they often thwart me, but – Yeah.

22:44 What – Hey, we'll try.

22:47 What frameworks did you use to build GUI?

22:49 Well, that was way back in the day.

22:51 I was using Windows 32, the raw Windows 32 API.

22:55 So it was a nightmare.

22:56 Oh, so you were down at the Charles Petzl Win32 layer, huh?

23:00 Oh, yeah.

23:01 Wow.

23:01 That's no VB.

23:02 Yeah, you don't mess around.

23:03 You go straight to a simulated learn programming.

23:05 You go to, like, the Win32 API to do GUIs.

23:08 That's awesome.

23:09 Okay.

23:09 So you said also that the front-end stuff had been jQuery and jQuery UI, but that you were all moving on to React, right?

23:17 Yeah, there's a couple groups.

23:18 There's, I think, another group in the company that's doing Angular, but the stuff that we're working on for the back-end applications is in React and then using an API to manage the conversation, but back and forth to the actual data representations.

23:33 Right, talking to stuff like the API tree building.

23:36 So how do you decide upon React?

23:39 I mean, I actually am still a bit of a fan of jQuery.

23:41 I just want, like, a little tiny bit of interaction.

23:44 Like, jQuery actually is not too bad.

23:46 It doesn't have all this setup.

23:47 Set the apps.

23:48 Set the models.

23:49 I mean, if you're building real apps, then React and all these things are cool.

23:53 But I still have some love for jQuery.

23:55 But tell me about why you chose React.

23:57 Well, I'll have to send you a link because I actually just gave a presentation at the last Engineering All Hands about there's still a place in the world for simple jQuery applications.

24:06 And I'll have to send you a link to that because I still like that.

24:11 Yeah, yeah, we'll put it in the show notes.

24:12 Because it's one of the reasons I like it.

24:14 It's quick.

24:14 You can get a prototype up and running very fast.

24:17 And it's not so costly in time that you wouldn't want to throw it away if it gets popular to rebuild it in something else, which is handy.

24:25 But React was – I was actually going down the path of Angular.

24:29 And then, you know, we sort of switched gears and I jumped on React.

24:33 And, well, anybody who's done this kind of work probably has come from another – who's come from another world.

24:39 You know, you wait five minutes in the JavaScript world and there's another framework out there.

24:42 It took me a long time to actually jump on board.

24:46 But I like the conceptual nature of – or the concept behind React where you have components that you can glue together.

24:53 And those components can have a visual and a behavior aspect to them.

24:59 Yeah, it's almost like the control programming model of, like, the older Windows systems and stuff.

25:04 Where you can – you know, I'm going to buy a grid control and I drop it here and now it does grid stuff.

25:08 That appealed to me because I had written – you know, writing a lot of jQuery code, you're sort of – this is a way I like to make my page look with HTML and CSS.

25:17 And then I'm sort of, you know, I'm bolting behavior to it with a – It is non-obvious where that behavior comes from in jQuery.

25:24 It's like I know it's hooking an event somewhere and I cannot figure that out.

25:27 Well, I've written some really huge jQuery applications and they're still being used.

25:33 And whenever anybody wants to add features to that, I'm, like, cringing.

25:36 I'm like, oh, no, please no.

25:37 Because there's so many side effects and ripples when you change things.

25:42 So it gets to riddle after a while.

25:44 I just reorganized it.

25:45 I put inside this div and it just stopped working.

25:47 Thanks.

25:48 I know.

25:49 I know.

25:49 Thanks for that.

25:50 Let's not do that.

25:52 But React seems more – I mean, I like the module system so that you can actually break it.

25:57 I like JavaScript.

26:02 And to me, in many ways, I know people don't like JavaScript who come from other languages.

26:08 But to me, it feels very complementary to Python, the whole idea of objects and arrays and the for each and all that kind of stuff.

26:15 And now that things like React and Angular, React in particular, has these idea of web components that have look and feel and behavior,

26:25 that feels like a real way to program a GUI, especially – Yeah.

26:31 Yeah.

26:32 It looks like a web platform as an application platform to deliver stuff.

26:36 Yeah.

26:36 That's interesting.

26:37 Have you thought about writing any desktop apps with, say, Electron.js?

26:43 I have.

26:43 I'm looking into that using – in my case, because I'm trying to get smarter on React, I'm thinking of React Native.

26:50 But I've seen some stuff written in Electron, and it's all very interesting.

26:54 And I want to get there because I like that stuff.

26:56 It's really interesting.

26:57 I wish it had an option for a Python backend.

27:00 Yeah.

27:00 And I just discovered – one of the listeners from the Python Bytes podcast sent me this thing.

27:06 It's more of a way to work with Electron that has a Python backend instead of Node.js.

27:12 Oh, neat.

27:13 And you get it – install it natively on the system.

27:16 It's called Python Electron.

27:18 Yeah.

27:18 I'll put that in the show notes.

27:19 I wish it was called Proton because Electron, Proton, Python.

27:22 But a name is missed here.

27:25 But it's really quite interesting.

27:28 And I think you could take React and the JavaScript and HTML and pair that with this Electron Python backend.

27:35 It would be very smart.

27:35 Oh, I think that would be great because I've written WX Python applications, which is a lot of fun.

27:43 It reminds me a lot of my Windows programming days.

27:45 And they're really cool, but they're so hard to port.

27:48 They're so hard to give to somebody because there's so much stuff you have to install that's very specific for the target platforms.

27:54 Right.

27:55 Make sure you have Python 3.4.

27:57 And then you're going to need to do this.

27:59 And then you've got to pip it like, whoa, this is not how I get an app.

28:01 I get it from the app store or something.

28:02 And then if actually somebody adopts it, any kind of update process to put changes out there is almost impossibly painful.

28:11 Yeah.

28:12 Yeah, yeah.

28:13 So this Electron Python would have its own auto-updating system and stuff.

28:16 It would be really neat.

28:17 And you package it all up and it's .app or .exe.

28:20 Yeah, that would be nice.

28:21 I'll have to dig into that.

28:22 I'm looking forward to that.

28:23 Yeah, yeah.

28:24 I'll put a link.

28:25 Cool.

28:25 Thank you.

28:26 Yeah, so when I was thinking of JavaScript front-end stuff, I'm kind of thinking about Vue.js as probably where I would like to work.

28:34 Although I don't have any intention to do tons of rich front-end work right now.

28:38 But, yeah, there's a lot of good choices.

28:40 But like you said, by the time this episode ships, there's going to be another one.

28:44 Well, a lot of the stuff I wrote was a whole combination of jQuery plugins.

28:48 I used jQuery, jQuery UI, data tables.

28:52 I used handlebars a lot to do templates within jQuery and HTML.

28:57 So it was a whole pile of stuff.

28:59 But it gets to be difficult to make the apps look consistent, one app to the next.

29:05 That gets to be hard to manage.

29:06 Yeah.

29:07 Maybe I'll have to check out React.

29:08 It sounds pretty good.

29:09 I think you'll like it.

29:10 I know Angular.

29:12 I was working with Angular, and I really liked that.

29:14 One of the big concepts with Angular is it feels like they're trying to add functionality to HTML.

29:20 And one of the differences I see with React is it's the exact opposite.

29:24 They're trying to add HTML to functionality.

29:26 So it's like embedding HTML into JavaScript.

29:28 Conceptually, it's a little different.

29:30 But one of the things I had trouble with was in Angular, it's sort of dependent on TypeScript, which I really like TypeScript.

29:37 But if you look at the code that's generated by that when it does the transpiling, thank God there's TypeScript because I definitely would not want to write that JavaScript.

29:46 Yeah.

29:48 TypeScript is interesting.

29:49 It has a lot of parallels back to the type annotations in Python 3.

29:54 But TypeScript, one of the things I'm not a fan of with TypeScript is it's a little more serious about the types.

30:02 Python is like, these types are here to help you.

30:05 If they get in the way, you can kind of just pretend they're not there.

30:08 Whereas TypeScript, it's like, no, you haven't declared this variable type that's in another file.

30:13 You know, it really is.

30:14 It can be a thing.

30:15 It gets to start to feel like C or Java in that way, that it's very strict typing.

30:19 Yeah, it really is.

30:21 But there's a lot of potential, a lot of potential with types, especially in the Python stuff.

30:26 We have Cython now understanding Python 3 types.

30:29 And then Dropbox is now talking about mypyC, which will take type annotated Python and compile it to C code.

30:36 I think that you guys mentioned that on either Talk Python to Me or in Python Bytes, you mentioned that at one time.

30:41 Yeah.

30:42 Yeah, I think in Python Bytes we did.

30:43 Yeah, that's really new.

30:45 And I think that's quite interesting.

30:46 Yes, absolutely.

30:47 So I think that leads into another area that you are passionate about is talking about whether it's Python, is it slow?

30:55 Does it perform well?

30:56 Is it going to solve your problems, right?

30:58 Like how do you measure performance anyway?

31:00 Well, that's the thing.

31:01 I mean, people, you know, from my embedded days, I know I'm a speed freak.

31:05 I want this thing to go as fast as possible.

31:07 You started out in assembly, right?

31:09 I mean, come on.

31:10 Yeah, right.

31:10 Every cycle counts on these little tiny machines.

31:14 But I'm a big believer in there's no sense in optimizing unless you measure.

31:18 And the other part of that is you have to have a target.

31:21 Like what does fast mean to you?

31:23 How fast does this have to be?

31:25 And why?

31:26 Why do you need it to be fast?

31:28 I think I've proven to myself many, many times more than I care to remember that every place that I think things are slow and I spend time optimizing it, I'm completely wrong about what makes the code slow by my intuition.

31:41 It's only by measuring that you find out this is where it's important to speed things up because you could spend a lot of time speeding up something that gets called once a day.

31:49 I've seen that happen plenty.

31:51 It's so easy to get the wrong impression because you see code that is complicated and you're like, that must be it because that looks super hard for me to understand.

31:59 But it's no, no, no.

32:02 You should have used a set instead of a list here.

32:04 Or something entirely trivial and it's just you would know if you had looks.

32:10 And if you're building a 24-7 server, that thing has a long life.

32:16 So there's lots of opportunities where things don't – they get called once an hour, once a day.

32:20 It's not that big a deal.

32:23 And it's very important to say, okay, where is this thing spending most of its time?

32:27 Is it busy?

32:27 And in my world today, there's lots – like I said, there's events that are minutes, hours apart.

32:32 So I need to pay attention to what matters.

32:36 Right, and if the part that instantiates the hour-long process takes an extra 10 milliseconds but it's easier to understand, let's not stress, right?

32:44 Because you could write – even in Python, you could write some obtuse code and I don't really want to read that again.

32:50 Oh, yeah.

32:51 And the other thing is that computers are so fast.

32:54 I mean it's long – we long since passed the tipping point where the computer's cycle time is more expensive than mine.

33:03 My cycle time is much more expensive.

33:05 In fact, my cycle rate is very slow.

33:07 So being able to develop code quickly is really important.

33:11 It's important.

33:12 You're absolutely right.

33:13 I totally agree with you on what are we optimizing for.

33:15 Are we optimizing for the computer or for the business or the project or the product or whatever it is, right?

33:22 Like if you can add two more features to your website a month but you pay an extra $20 in hosting, who cares?

33:32 Yeah, exactly.

33:32 Right?

33:34 Yeah, if I can get something forever that meets some target window, marketing window or product window, that's far more important than if I'm saving a millisecond here or there by thinking of some crazy way of doing things.

33:47 Right.

33:47 Or say, forget it.

33:48 We're going to go.

33:49 Or forget it.

33:50 We're going to write it and see.

33:52 I think there's a couple of interesting options there.

33:54 One, you say you need to measure and see what's working.

33:56 Like you could rewrite the two slow functions if they're, you know, computationally slow in Cython and probably make those go nearly to zero.

34:05 Yeah, exactly.

34:06 Something crazy like that.

34:07 And just a tiny bit and not have to completely re, you know, throw the baby out with the bad boy sort of thing.

34:12 Oh, I often find that idea of adding like the optimization flag to see gives you like really incremental improvements versus doing algorithmic optimization.

34:22 Like I'm improving the algorithm.

34:23 My data structure is better where you get orders of magnitude improvement in speed.

34:29 Yeah, yeah, you choose the wrong data structure, not just the algorithm, even just the wrong data structure.

34:33 And it could be a thousand times slower because you said, well, I always put stuff in a list.

34:37 But really what I wanted was a dictionary because I'm randomly looking up stuff.

34:41 I'm not looking it up by index.

34:42 Right, exactly.

34:42 Yeah, pretty interesting.

34:44 This portion of Talk Python to Me is brought to you by Rollbar.

34:50 Got a question for you.

34:52 Have you been outsourcing your bug discovery to your users?

34:54 Have you been making them send you bug reports?

34:57 You know, there's two problems with that.

34:59 You can't discover all the bugs this way.

35:01 And some users don't bother reporting bugs at all.

35:03 They just leave, sometimes forever.

35:05 The best software teams practice proactive error monitoring.

35:09 They detect all the errors in their production apps and services in real time and debug important errors in minutes or hours, sometimes before users even notice.

35:17 Teams from companies like Twilio, Instacart, and CircleCI use Rollbar to do this.

35:22 With Rollbar, you get a real-time feed of all the errors.

35:27 So you know exactly what's broken in production.

35:28 And Rollbar automatically collects all the relevant data and metadata you need to debug the errors so you don't have to sift through logs.

35:36 If you aren't using Rollbar yet, they have a special offer for you, and it's really awesome.

35:40 Sign up and install Rollbar at talkpython.fm/Rollbar.

35:45 And Rollbar will send you a $100 gift card to use at the Open Collective, where you can donate to any of the 900-plus projects listed under the Open Source Collective or to the Women Who Code organization.

35:56 Get notified of errors in real time and make a difference in Open Source.

36:00 Visit talkpython.fm/Rollbar today.

36:04 Another thing that you spoke about was that you're not the youngest programmer.

36:09 You said you started out in the 80s, right?

36:11 And this is something I'm passionate about because running the podcast, people reach out to me a lot and say,

36:16 Michael, I'm 40.

36:17 It's too late for me.

36:18 I can't do any of this programming stuff.

36:20 Like, programming is for young folks.

36:22 I myself am, you know, not especially young.

36:25 But I see the programming space as quite vibrant for people.

36:28 I teach at this STEM school, STEM education place near me, and I teach programming Python to kids there.

36:35 And I've written some material there.

36:36 And I've been trying to – I've been twisting the guy who runs the place.

36:40 I've been twisting his arm to think about that he really needs – he really should market to older adults

36:46 because I think that this is – you know, like they say, like, crossword puzzles is a good way to keep your mind sharp.

36:52 I think this is, like, the greatest crossword puzzle ever is kind of programming.

36:55 Yes.

36:56 And it's – It absolutely is.

36:57 It's so engaging and you have to think deeply.

37:01 It's better than video games.

37:04 It's certainly better than Sudoku.

37:06 Oh, yeah.

37:08 Yeah, absolutely.

37:09 And it's – with languages like Python and, you know, some of the other modern scripting languages, it's so accessible.

37:15 There's no – there's no, you know, the whole – I would never want to.

37:19 I mean, I really considered myself a very strong C++ programmer.

37:23 But I would never want to start there again because the whole idea of the linker and the include files was just – would make you crazy as a novice programmer.

37:31 Remember the times when the header and the .lib file would get out of sync?

37:35 Yes.

37:35 And it would just not – you're like, why is this just crashing randomly?

37:39 Like, I don't even understand.

37:40 Like, so glad that problem's gone.

37:41 Oh, yeah, me too.

37:42 I don't want to – I mean, I like that stuff, but I don't want to go back there.

37:45 Yeah, for sure.

37:46 I think this is a really interesting idea of having a programming class for older adults.

37:51 You know, Philip Guo, who was at UCSD, I had him on Talk Python a while ago about programming in your golden years.

38:00 And said a lot of folks who were starting to retire and were learning programming actually were doing so to connect with their grandchildren.

38:08 Because their grandchildren were in Minecraft or they wanted to do, like, robots.

38:12 And they're like, well, I'd like to do that with them.

38:14 Apparently, that requires programming like JavaScript and Python.

38:17 So I'm learning it, right?

38:18 Yeah.

38:19 I had taught – this is a stupid story.

38:21 But years ago, I had taught a couple of adult ed classes to help people get into Windows and DOS.

38:27 This is how far back it goes.

38:28 And I would be up there.

38:29 You know, I'd be talking.

38:30 I would be talking about something.

38:31 And it invariably would happen.

38:33 I would say, okay, I want you to enter this command.

38:35 And I'd turn to the whiteboard and I'd write on the whiteboard.

38:38 And behind me, I'd hear this beep, beep, as people were restarting their computers because they had typed something wrong.

38:44 Oh, my God.

38:47 Because they were so afraid of getting it wrong.

38:49 I'm like, no, you can't hurt it.

38:50 Just go with it.

38:51 Yeah.

38:52 Unless you write format, you know, C colon slash Y or something, you're going to be fine.

38:57 You're okay.

38:59 And for me personally, you know, I committed to – as I came to it late and I committed to – I'm a self-taught programmer and was always – and I've changed languages a lot.

39:11 But I had to learn new languages.

39:12 So I committed to this sort of constant learning idea early.

39:16 And I've stayed with it my whole career.

39:19 And it's really paid off because I'm still able to learn new things.

39:24 I'm learning new things all the time.

39:25 It works like I'm learning React, for instance.

39:27 And a little bit of Erlang, for crying out loud.

39:29 Wow.

39:30 But it's because of – you know, there's this habit that I have – that I learn constantly that I'm able to stay competitive and be – and contribute to a team of mostly younger guys.

39:42 And, you know, mentor people based on my experience and able to learn from people.

39:48 So I hope that I'm not overbearing about that.

39:51 But I'm able to learn from other people because there's a lot of people who are – they have – you know, they don't even know what assembly language is.

39:57 But they have a valuable skill that I want to learn and know about.

40:01 Yeah, absolutely.

40:01 Do you feel like being a self-taught programmer was maybe harder in the beginning but has paid off now that you sort of force yourself to be able to figure it all out?

40:10 Yeah.

40:11 When I moved into software development full-time from – it was the same company I was doing the process controller work.

40:17 I moved to their software group.

40:19 And all those guys had MSs and doctorates in computer science.

40:23 And so I was playing catch-up all the time on Fortran and C programming.

40:28 And so I worked really hard.

40:30 One of the things I did, my boss was a very sharp guy.

40:32 And I would hit a problem.

40:34 You know, my goal all the time was like I would work at it, work at it, work at it before I go ask him a question.

40:40 The deal was – and I would try to make it so he didn't answer the question within one minute.

40:45 And I – in five years, I failed every time.

40:48 He would – but at least, you know, I did the work to ask intelligent questions to get there.

40:54 Yeah.

40:54 That's a really good point.

40:56 You know, I'm also more or less a self-taught programmer.

40:59 I took, you know, a couple of programming classes, C++, Fortran in college and stuff.

41:05 But for the most part, I studied math.

41:07 And I feel like there was always this little bit of imposter syndrome feeling like, well, I know – are we talking about like, you know, what happens deep down in the operating system?

41:17 Well, I didn't take the operating system class.

41:19 I don't know maybe as well as that person, right?

41:20 But I know that I taught myself all of this programming stuff.

41:26 And there's basically nothing that scares me.

41:29 Right.

41:29 Well, not nothing.

41:29 But not much that scares me because it's like, well, I've come this far by forcing myself to do it.

41:36 And you just – like you said, you get into this habit of I spent the last 10 years just continuously learning these things and making these steps.

41:44 And so I know to get to wherever you want to be, it's like just more steps.

41:47 Absolutely.

41:48 And those two things, they drive me pretty hard to constantly learn stuff that I don't know.

41:53 But I also know myself.

41:55 I'm an applications engineer.

41:57 I need to apply this stuff.

41:59 So, you know, red, black trees and that kind of, you know, AVL automatic balancing stuff is like – I mean, yeah, okay.

42:06 I'm just going to throw a dictionary at that.

42:07 It solves the problem.

42:08 Yeah.

42:10 So there's gaps in my knowledge that I don't have.

42:12 But on the other hand, I haven't run into too many cases in a long career where I've really needed that stuff.

42:17 So for me, I just – I need to know the stuff that is applicable to my job.

42:21 Yeah.

42:22 You know, a lot of people who take computer science have to do things like calculus and differential equations and stuff.

42:27 I don't know many programmers who still do differential equations.

42:30 I know there are some.

42:31 Yeah.

42:31 But not most of them, right?

42:33 Most of it, it's like, well, algebra, maybe a little geometry, maybe.

42:36 Well, sometimes I make this joke at work all the time.

42:39 Like they often lean on math teachers to be the computer teachers at schools.

42:45 And I'm like, yeah, I don't know if that's the right choice.

42:47 Sometimes I think it should be English majors because most of my life is tearing apart strings all day.

42:53 That's true.

42:55 It is a lot of text, isn't it?

42:57 It's a lot of text.

42:58 So, but while we have a little bit of time left, I'd like to talk about some of the articles that you've written.

43:03 Because, like I said, that's how I got to know you.

43:05 You said a big part of your day-to-day work is working on these REST APIs with Flask.

43:10 And you wrote a couple articles on realpython.com about connection with an X for REST APIs.

43:18 Do you want to tell us about the articles and maybe give us a little overview of what connection is and how it's helpful?

43:23 Yeah.

43:23 I started using it because as I was moving away from all of the form validation and stuff like that and getting more into writing REST APIs,

43:33 I was looking for ways to make that nicer, make that cleaner.

43:36 And actually, another guy introduced me to Connexion.

43:40 And that is a really nice tool.

43:43 It does two things that I really like.

43:45 Besides providing the automatic interactive documentation through the Swagger UI system, the configuration file that drives it is a nice way to think about the API.

43:55 So, you can sort of structure what the API is going to look at, look like, and what it's going to accept long before you get into code.

44:04 Because you can really go down a rabbit hole where you're like, okay, I'm focused on the code for this one endpoint, this URL endpoint.

44:10 And you can get to a point where you're like, oh, you know, if you looked at the API as just a list of URLs, they could look like a real mess and not make much sense.

44:21 And Swagger, or excuse me, Connexion helps you think about that in, I think, much clearer ways and structure the system.

44:29 Plus, whenever I've shown off, whenever I show off my stuff and I show the Swagger UI, everybody's really impressed.

44:37 It's helped the front-end guys to be able to look at the API and use it without actually having to write any code themselves and see how it behaves and what it's expecting, what it returns, that kind of thing.

44:49 And that's been very powerful.

44:52 Yeah, the documentation is really cool, actually.

44:54 Yeah, it's fantastic.

44:56 Because, you know, I definitely prefer the REST APIs over other options that have been popular, like SOAP services and stuff.

45:04 But one of the things about those bad SOAP services is you could ask it what functions were there and what you're supposed to do with them, right?

45:11 Whereas, like, an arbitrary HTTP API, you're just like, well, I better go figure out some URLs and then start trying to understand the JSON because that's pretty much it, right?

45:20 And so Swagger gives you a nice view over top of that, right?

45:24 Yeah, a really very nice, you know, a consistent standardized UI.

45:29 I mean, they're constantly reproving it to interact with the API once you get it up and running.

45:34 And I think if you spend time, it does take time to build a configuration file because you're defining all the parameters and what they look like and giving them documentation strings.

45:44 But the payoff is the interactive UI that Swagger provides that gives you the documentation for someone who's interested of the parameters, what they mean, what this thing expects, the types of data for that JSON is going to send you or that it expects from you.

46:02 And that's really powerful.

46:03 Yeah, nice.

46:04 So you have this Swagger YAML file that defines the API basically and generates the help.

46:08 How do you get the, like, where does connection and your code all fit together?

46:14 Well, I know how to write a general, like a normal Flask API.

46:19 I would put at route and I would return Flask.jsonify.

46:22 But what do I do in this connection on the world?

46:24 Well, if you start configuration, the handshake point, the connection point between the configuration and the code, there's one specific parameter.

46:33 I think it's, what is it?

46:35 Object ID or something like that.

46:38 It's, I can't remember off the top of my head, but that is, that specifies the path to the handler for that particular URL endpoint.

46:48 So you might have, you know, it's just a string.

46:50 It'd be like my code dot my app dot my method within that app.

46:56 And Connection is smart enough to actually introspect your code and find that.

47:02 You know, it'll navigate down that path, importing modules as it goes until it finds that handler and connect that to essentially doing the at route.

47:11 It will create that within Flask to handle that URL when that gets called.

47:16 So it's a very nice way.

47:18 I see.

47:19 You know, it auto connects that, this piece, the configuration piece with the code that's going to handle that configuration.

47:26 Oh, that's cool.

47:26 So it finds the Python files and implement it and sort of does the connection for you.

47:30 Yeah.

47:30 I guess it's the name.

47:31 And it tells you, you know, it tells you if you don't have one.

47:33 Like I've often misspelled things and it'll tell you, nope, that doesn't exist.

47:37 No connection there.

47:38 Yeah, too bad.

47:40 Okay, this looks really nice.

47:41 So you have a couple of nice articles on that and people can look through there.

47:46 Yeah, on RealPython I've published some articles, two articles actually, on this REST, this FlaskConnection REST API.

47:52 The first one was just an in-memory structure that I wanted to talk.

47:56 It was a long enough article that I just wanted to talk about REST and my interpretation of REST because it's not really a spec.

48:03 It's just a convention.

48:03 And then the second article, which sort of was spawned by people asking me in the comments, hey, how could I make this thing persist to a database?

48:12 So I took the basic API and code and then added a database connection through SQLAlchemy using SQLite as the database.

48:21 Yeah, that's the way to do it.

48:22 Very nice.

48:23 I love SQLAlchemy.

48:24 Oh, it's terrific.

48:24 I'm not a big SQL guy, so I like that Pythonic way of thinking about it.

48:29 Yes, I'm with you on that.

48:31 So that was on RealPython.

48:34 You also did some on dbader.org, which is kind of similar because Dan Bader runs both sites.

48:42 Yeah, he runs both sites, right.

48:43 So it's a little bit of a connection there.

48:46 You did one on just sort of Python, getting started with Python.

48:50 But one I thought was pretty interesting.

48:51 I actually used this as a little bit of research for my recent async course.

48:55 Yeah, I was very happy to see that.

48:56 Yeah, the one's called Understanding Async Programming in Python.

49:00 Yeah, I had maybe 10 or 15 articles I read to just see what people were doing.

49:04 And this is a nice one.

49:06 And this talks about very much of what you kind of hinted at the beginning with G event, with Twisted, and some of those things, right?

49:13 Yeah, this was an article that actually came out of a presentation I gave at one of the Shutterfly All Hands meetings.

49:20 And I had been in touch with Dan about the first article, just the Python introduction.

49:26 And then he and I talked, and he was interested in this asynchronous one.

49:30 And I put that together.

49:31 It's a passion of mine because I like this whole asynchronous way of thinking.

49:36 I've written threaded code in C and C++ and lived to regret it.

49:41 And this whole asynchronous way of thinking, although at first it's hard to get your head around, it's a really interesting way to work if you have a program that's a mix of CPU and I-O bound processes or tasks.

49:56 And I talked about that in my – one of the things I find interesting is people have – I've taught asynchronous programming to my coworkers and talked about it a lot.

50:07 And there's just like this real hurdle to get over for people to get their heads around it.

50:12 And it's interesting to me because in reality, humans are asynchronous.

50:17 Our behavior is asynchronous all the time.

50:19 But to think about it in this linear presentation of code, it's kind of hard to break out of that linear execution model.

50:28 But as you mentioned in my article, I had these sort of thought experiments about different kinds of way that if people were synchronous or how do you handle asynchronous behavior.

50:38 Exactly.

50:39 You know, if as a parent, you could only cook dinner and then tell your child to, you know, get ready for bed and then serve dinner.

50:49 And yeah, it doesn't make any sense, right?

50:51 The real world definitely is asynchronous.

50:53 Oh, yeah.

50:54 I like the polling parent one where you're running back and forth checking every two minutes on everything that's going on.

50:59 Is the dinner ready?

51:01 Is the kid getting ready?

51:03 Is the laundry – is the washing machine done?

51:05 No?

51:05 Yes?

51:06 No, no?

51:06 How interesting.

51:07 Yeah, so this is a cool one.

51:09 I would love to see a follow-up with some async I.O., maybe some A.I.O.H.D.P. or something like that.

51:16 That'd be fun.

51:17 Yeah, I'm going to talk to Dan about maybe how he feels about updating existing articles because I want to take that to the next level with async I.O.

51:25 I haven't had an opportunity to do much of that in my data way of work, but I'm definitely heading that way because I'm thinking, like I said, I was thinking about Quart and Sanic.

51:35 And I like it that it's native to Python now, the async stuff.

51:40 Yeah, and especially the async and await keywords.

51:46 Like you say people have this hard time thinking about async as code and whether it's something like G event or it's JavaScript with their callback mechanisms.

51:56 I think it's hard because you have to unravel or turn your code inside out.

52:00 I'm going to start this and then it's going to call this other thing to continue it and so on.

52:04 But with async and await, you write your code in the serial form and then you just drop in some awaits in the various places.

52:10 Yeah, it's great.

52:10 And it's beautiful.

52:11 I love it.

52:12 It's really, really nice.

52:13 I've talked to some of my friends who are like the front-end guys I work with who are friends of mine.

52:18 You know, they're used to this whole asynchronous method in JavaScript.

52:21 But in some ways, they're still sort of in the mind frame of like they're thinking linearly because you see this deeply indented callback hell for their handling asynchronous events.

52:31 And it's one of the things I like about React is it helps you break out of that.

52:35 Yeah, that is really nice.

52:36 Yeah, that deeply indented callback stuff.

52:38 It's just hard to deal with if something goes wrong.

52:41 It's like, well, where do I unravel this to?

52:43 Yeah.

52:44 I'm halfway down this hole and I don't know where to go from.

52:46 What am I doing now?

52:48 Yeah, this is the problem.

52:50 So you've got to take your step back each level out.

52:52 But, yeah, I'll put that in the show notes.

52:54 People will definitely enjoy that.

52:56 So we're down to just a few minutes, a time left.

52:59 So I suppose I'll ask you the two questions here at the end.

53:03 All right.

53:03 So if you're going to write some Python code, what editor do you use?

53:06 Well, currently I'm an IntelliJ editor user and with the Python module plug-in.

53:12 I used to use PYCharm, but now I'm covering so many languages, it's useful to work in IntelliJ so I can jump back and forth.

53:19 Sometimes I have to do code reviews in Java and look at JavaScript and some other things.

53:24 Right.

53:25 So IntelliJ is really great.

53:27 I don't understand people who don't want to use an IDE with a debugger.

53:31 I just don't get it.

53:33 Yeah.

53:35 You and me both.

53:36 I'm such a fan of it as well.

53:38 I think it's really great.

53:39 So if you're an IntelliJ-based person doing PYCharm or something, Brian Okken shared this with me today, this thing called Power Mode 2, which is one of the plugins.

53:47 The faster you type, it will start to shoot flames and sparks from your code as you type.

53:52 So if you need to do a presentation show off, you plug that in and take it to the next level.

53:57 It's, of course, completely silly but fun.

53:59 I might try that because one of the best things my mom ever made me do was I took a typing course in sixth grade and it's paid off because I type pretty fast.

54:10 A lot of programmers don't, but I type pretty quick, so I'll definitely try that out.

54:14 Yeah, all fun with that.

54:15 Definitely for presentations.

54:16 All right.

54:17 So notable PyPI packages?

54:18 Well, I really like, as I mentioned, Connexion, which is this REST API.

54:22 And then the other side of that is Marshmallow, this serialization, deserialization library that lets you, because SQLAlchemy deals with Python objects, you can't just hand those off to something that wants to turn them into JSON like Connexion.

54:37 Right.

54:38 If you try to return it out of your method, it'll freak out and go, I cannot serialize this thing to JSON.

54:42 Yeah, there's no matching thing for a Python date-time object in JSON.

54:48 So this Marshmallow thing allows you to, just as you would in SQLAlchemy, build a model that matches your table structure.

54:55 Marshmallow does the same thing, but it builds a model that tells us, oh, this is the data I'm expecting, this is the structure, and this is how I'm going to convert it to something that's JSON-able.

55:07 That is cool.

55:09 And back and forth.

55:09 It does both.

55:09 Yeah, that's really cool.

55:10 I should definitely learn about Marshmallow.

55:12 Oh, it's sweet.

55:13 It has the same thing as SQLAlchemy, where you have relationships, the one-to-many, many-to-many relationships in the data table.

55:20 You can also set those up in Marshmallow so that if you have a SQLAlchemy object that has, you know, you've got one record, but it's got many relationships to others.

55:29 Marshmallow will take care of that as well.

55:31 It'll just go down the tree and serialize them all.

55:35 That just does the whole object graph.

55:36 Wow.

55:37 Yeah.

55:37 Very nice.

55:37 You take that return value and you hand it off to – you return it from your call, and Connection will then turn it into a JSON string.

55:44 Okay.

55:45 I'm loving this one.

55:46 Good choice.

55:47 All right.

55:49 Well, this – yeah.

55:50 This has been really interesting.

55:51 I really appreciate you being on the show, Doug.

55:53 Oh, I'm very glad to be here.

55:55 It's great.

55:55 I've really enjoyed it myself.

55:56 Yeah, absolutely.

55:57 You got a bunch of recommendations, and I think a really interesting way to look at that whole async programming thing.

56:02 So I'm looking forward to your follow-up articles that you write about this.

56:05 Yeah, definitely be fun.

56:07 I love that little bit of extra complexity and then being able to do many things at once is not only important to me but fun as well.

56:14 Yeah, it's definitely fun.

56:15 Yeah, we don't need to do crossword puzzles or Sudoku.

56:18 We can just work on our threaded code, right?

56:20 Yeah, right.

56:21 In my classes, I teach the kids using the turtle module because I get them right into drawing on the screen.

56:28 I do the same thing with adults.

56:30 It would be great, I think.

56:31 Yeah, absolutely.

56:31 It would.

56:32 All right.

56:33 Well, thanks for being here.

56:34 Good to talk to you.

56:34 Thank you, Michael.

56:35 Bye.

56:36 Bye-bye.

56:36 Bye-bye.

56:37 Bye-bye.

56:37 This has been another episode of Talk Python to Me.

56:40 Our guest on this episode has been Doug Farrell, and it's been brought to you by LogRocket and Rollbar.

56:46 LogRocket will help you avoid the back and forth, helping your users with problems on your site.

56:51 Visit talkpython.fm/LogRocket to get started with their free tier and get a pixel-perfect replay of what your users saw and the state of your app.

57:00 Rollbar takes the pain out of errors.

57:03 They give you the context and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complained, of course.

57:10 Track a ridiculous number of errors for free as Talk Python to Me listeners at talkpython.fm/rollbar.

57:18 Want to level up your Python?

57:19 If you're just getting started, try my Python jumpstart by building 10 apps or our brand new 100 days of code in Python.

57:26 And if you're interested in more than one course, be sure to check out the Everything Bundle.

57:30 It's like a subscription that never expires.

57:32 Be sure to subscribe to the show.

57:34 Open your favorite podcatcher and search for Python.

57:37 We should be right at the top.

57:38 You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.

57:47 This is your host, Michael Kennedy.

57:49 Thanks so much for listening.

57:50 I really appreciate it.

57:51 Now get out there and write some Python code.

57:53 I'll see you next time.

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon