Latest / Talk Python To Me / #182: Picture Python at Shutterfly
Transcript
- 0:00Join Doug Farrell and me as we discuss his career and what he's up to at Shutterfly.
- 0:04You'll learn about the Python stack he's using to work with not just bits and bytes,
- 0:09but physical devices on a production line for creating all sorts of picturesque items.
- 0:14You'll also hear how both he and I feel it's a great time to be a developer,
- 0:18even if you're on the older side of, say, 30, 40, or beyond.
- 0:21This is Talk Python To Me, episode 182, recorded October 4th, 2018.
- 0:27Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
- 0:46This is your host, Michael Kennedy. Follow me on Twitter where I'm @mkennedy.
- 0:50Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.
- 0:57This episode is brought to you by LogRocket and Rollbar.
- 1:00Please check out what they're offering during their segments. It really helps support the show.
- 1:04Doug, welcome to Talk Python.
- 1:06Thank you very much, Michael. I'm glad to be here.
- 1:07Yeah, I'm glad to have you here. It's great.
- 1:09We've been interacting on email and on social media and stuff.
- 1:13I've talked about some of the articles you've written before, and you've sent in recommendations and various things for us.
- 1:18So it's nice to finally have you here.
- 1:20Yeah, 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.
- 1:29Yeah, there are definitely some good ones.
- 1:30And I want to dig into some of those, actually, as we get further into the show.
- 1:33But let's start with your story about how you got into programming in Python.
- 1:37Well, I actually got started pretty late.
- 1:39I was probably in my late 20s by the time I got into programming back in the early 80s, late 70s, early 80s.
- 1:47I 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.
- 2:02I didn't really get excited about it until it was either.
- 2:04Yeah, I could see how you wouldn't be so excited about that.
- 2:06That's not the same as, you know, fun GUI editors and compilers and Stack Overflow and all that stuff, right?
- 2:13It's a different world.
- 2:14Well, 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.
- 2:21The 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.
- 2:27They just lost their will to be part of that anymore.
- 2:31That's it.
- 2:32They'd moved on to something else.
- 2:33So 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.
- 2:49How interesting.
- 2:50You know, you think of, like, getting started programming.
- 2:52People say, well, Michael, programming's kind of hard.
- 2:55I have a hard time wrapping my mind around, like, Python or JavaScript.
- 2:58Like, starting with a similar.
- 3:00Like, that is starting.
- 3:00Seriously.
- 3:01I still can't do similar.
- 3:03The color computer was so slow.
- 3:05It was less than a megahertz clock speed.
- 3:07So to do anything fast, you had to really get down and dirty.
- 3:09Yeah.
- 3:10But, okay, so you started there.
- 3:11So that gives you a good foundation of it's only going to get easier from here.
- 3:15Right, yeah.
- 3:15And I had my – actually, I was back in school by then going after my physics degree, BS in physics.
- 3:22And 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.
- 3:34And that really – I really enjoyed that.
- 3:37I spent most of my time doing that besides failing French.
- 3:40And 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.
- 3:50Wow, that sounds interesting.
- 3:52So that's a lot of, like, controlling hardware, right?
- 3:55Right, yeah.
- 3:55Which is kind of a theme, it sounds like, from all the stuff that you've been doing.
- 3:58Yeah, it was kind of a big scale, you know, like a macro version of hardware control where you're doing really huge systems.
- 4:05I think the biggest thing I did was I automated a 35-gallon-a-day, 35-million-gallon-a-day clean water system in Arizona.
- 4:14I think about – there were certain steps in my programming career that they were sort of, you know, take-your-breath-away moments.
- 4:23And 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.
- 4:34I was like, wow, I had really better not mess this up.
- 4:38You know, if we do this wrong on scale, it's going to be a problem.
- 4:40Did you have that feeling when you were working on that much water and that much hardware?
- 4:45Yeah, because the scale of this thing is huge.
- 4:47I 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.
- 4:53We were able to ride our bikes inside of the 35-million-gallon tank because it wasn't in use yet.
- 4:59You had your own velodrome.
- 5:00Yeah.
- 5:02And 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.
- 5:11Hopefully no one was putting at the time.
- 5:13Well, 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.
- 5:21So that was a nice escape.
- 5:23Well, that's really good.
- 5:25That's really good.
- 5:25So what languages were you using to do all this?
- 5:27This was a proprietary language that the company had written.
- 5:31It was a software simulation of hardware.
- 5:34So 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.
- 5:48And this simulated those.
- 5:50And in that language, the variables – you could think of the variables as wires.
- 5:55So anything you connected a variable to was like wiring those two things together.
- 5:59So 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.
- 6:12Yeah, that's really interesting.
- 6:13Do you see as much of those sort of custom programming languages now?
- 6:18Or do you see people adopting things like Python and JavaScript and other languages for that purpose?
- 6:24Well, I know that that company is still big in the game and they're still around.
- 6:29And I think my experience with municipalities and gas pipeline companies is that they're very reluctant to change.
- 6:37They're always going to stick with something that works.
- 6:39I don't know if you've ever worked with PLC controllers, programmable logic ladder controllers.
- 6:44Yeah, I only have heard the term.
- 6:45Those are very popular because they work and people know them.
- 6:50So the same thing applies to municipalities.
- 6:52It works and they know them.
- 6:53I 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.
- 7:07So they expected our computer stuff to last like 50 years like a manhole cover.
- 7:11And I was like, really?
- 7:12I don't think so.
- 7:13This is not going to work out the way you think this is going to work out.
- 7:18So that was nice.
- 7:20Yeah.
- 7:21They were like, well, how are we going to get parts to replace this?
- 7:24I'm like, no, you're going to replace the whole thing in about 20 years, I think.
- 7:26Maybe even less.
- 7:27Yeah, how interesting.
- 7:28You moved on from there, right?
- 7:30Towards the web?
- 7:31Yeah, after I left that company, I worked at a high-speed pick-and-place machine.
- 7:37It was kind of a robot that assembled electronics boards by picking up chips, flying them over a camera, put them on the board.
- 7:43And about, I don't know, the fast one was like 20,000 parts an hour, which is really moving.
- 7:49And that was my really—
- 7:50Kind of stay away from it, right?
- 7:52Don't get too close to it, huh?
- 7:53Yeah, there was lots of stuff about don't open the door when it's moving because you could get really hurt.
- 7:59And 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.
- 8:06Yeah, I can imagine.
- 8:07But that was sort of like my low-level embedded programming, which I really enjoyed.
- 8:10And 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.
- 8:20And now I worked at Shutterfly.
- 8:22This is probably pre-Wikipedia, right?
- 8:25Yeah, this was back in the Encarta days and Griller's Encyclopedia Online.
- 8:31And I actually worked on the CD-ROM version of that and then the web version.
- 8:35Yeah, cool.
- 8:36Yeah, and now you're at Shutterfly, and it sounds like a really interesting place to be.
- 8:41And it also sounds like you're getting to do some of this sort of software meets hardware thing.
- 8:45Yeah, it's satisfying.
- 8:46I really like that part where software meets the real world.
- 8:48It's not just all a bunch of bits moving around in the computer.
- 8:51It has enough of the things that I write.
- 8:54Everything I write is all on our production floor, not customer-facing.
- 8:57So it allows our production people to interact with the presses and other machinery that actually produces books.
- 9:05Shutterfly is a digital book publisher where customers can upload their photos and get all kinds of products.
- 9:11Like photo books you can send out for gifts or printed stuff or printed photos out of your digital photos, things like that.
- 9:18Pillows and coffee mugs and desk frames and all kinds of big canvas prints, which are all interesting products.
- 9:25Our motto at Shutterfly is sharing life's joy.
- 9:29So it's an interesting way to think about photos and how there's so many digital photos.
- 9:35And then people get so many and they get overwhelmed about what am I going to do with this thing, this pile of pictures.
- 9:40You know, I just did that.
- 9:41I ordered a photo book for my family because we have like 30,000 photos.
- 9:45And I'm like, we're not going to go through these.
- 9:47There's just – it's overwhelming.
- 9:48But if I could put it on the coffee table and friends come to visit, like we can experience them in a different way.
- 9:53It's pretty cool.
- 9:54Yeah.
- 9:54It makes great gifts.
- 9:55I mean, you know, grandparents.
- 9:56I know my daughter sends me books that she makes with our product.
- 10:01And I love that stuff.
- 10:03Hey, you printed this for me.
- 10:05You just don't know it.
- 10:05Yeah.
- 10:06Usually, hopefully, I don't find out that I printed it and made it wrong.
- 10:10That's right.
- 10:11This is messed up.
- 10:12Oh, I remember that, Bob.
- 10:13Yeah.
- 10:13Oh, sorry.
- 10:14Yeah.
- 10:14So 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:25Yeah.
- 10:26It's not as dangerous as like high-speed stuff where people could get hurt.
- 10:29Yeah.
- 10:30You don't want to be putting people onto a board.
- 10:32No.
- 10:33Yeah.
- 10:34This sounds like really fun.
- 10:35And it's that software meets hardware thing.
- 10:37And you guys use a lot of Python at Shutterfly, right?
- 10:40Yeah.
- 10:41They actually – they acquired the company I was working for and we were doing all Python stuff.
- 10:45We were one of their smaller competitors and they acquired us.
- 10:48And I came on board as a full-time Shutterfly employee, which was great.
- 10:52And that was their first exposure to Python.
- 10:56They had been a traditionally and still are a big Java shop.
- 11:00A lot of the work that they had done and a lot of their infrastructure is in Java.
- 11:04But 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:16Yeah, of course.
- 11:17But 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:31But the gifting products are becoming – is a fast-growing market for them.
- 11:36And 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:44And almost that whole – almost the whole stack for that production is in Python.
- 11:49That's really cool.
- 11:50Do you guys see the agility and the ability to, you know, pip install anti-gravity to – as a real advantage for your team?
- 11:59Maybe even within the company, people go, oh, yeah, we know those guys can deliver quick.
- 12:03Yeah, that's a – there's two parts of that is that we can be extremely agile.
- 12:08And 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:20And 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:30And 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:38Yeah.
- 12:38Yeah, 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:45And YouTube was a little upstart built on Python and they were just out, you know, outperforming and adding features.
- 12:52Maybe they needed more servers or something to make it go, but it didn't matter, right?
- 12:56So kind of like you, Google – or like Shutterfly, Google solved the problem by buying YouTube and that fixed it.
- 13:03Yeah, 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:16And it's – we're doing a lot of infrastructure work.
- 13:19Any growing company has to do a ton of infrastructure work all the time.
- 13:23And 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:31And like you said, the pip install thing, we have our own PyPy server.
- 13:35Oh, nice.
- 13:36With modules that we have figured out are safe and to use and build against.
- 13:41But 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:48I'm twisting people's arms to get it into our server so I have access to it.
- 13:52That's really cool.
- 13:53So what technology are you using for your private PyPy server?
- 13:56Well, we have just a copy of the PyPy server code.
- 13:59It doesn't have the whole front end, but it just has the back end where you can just do a pip install.
- 14:04So long as you point at that server with a pip config file.
- 14:08Right.
- 14:08So you can configure –
- 14:09It will just grab files.
- 14:10Yeah, you can configure your user profile.
- 14:11So if you say pip install, it first looks there, right?
- 14:14Yep.
- 14:14That's pretty cool.
- 14:14My own development.
- 14:15We're moving from server-side development to client-side where we're using containers, Docker containers.
- 14:22And for that stuff, it's much – we often – this is how stuff gets started.
- 14:27We'll often grab a module from the regular, the public PyPy server, PyPI server.
- 14:33And 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:42Yeah.
- 14:42Nothing is a more convincing argument than success.
- 14:45I know.
- 14:46I've been in so many places where people debate, oh, if we do it this way, it'll be better.
- 14:50No, that way, it'll be better.
- 14:51Like, you know what?
- 14:51We're just going to build – like, I just built it this way.
- 14:53I know you said it can't work, but here it is working.
- 14:55Can we discuss whether or not it's still working?
- 14:58Yeah.
- 14:58Okay, fine, it's working.
- 14:59Yeah, you're right.
- 14:59That would work.
- 15:00Delivery often wins.
- 15:01Let's do that.
- 15:01Being able to deliver wins.
- 15:02Yeah, it certainly does.
- 15:03This portion of Talk Python To Me is brought to you by LogRocket.
- 15:09LogRocket will help you view errors in activity from your user's perspective.
- 15:13Did they tell you they couldn't log in?
- 15:15Well, with LogRocket, you'll get a session where you can see a pixel-perfect replay of what your user saw at that moment.
- 15:21The ability to inspect the state of the application at any point in time.
- 15:26You'll view every network request and response on their session, as well as a console log of all the JavaScript messages and errors.
- 15:33And it goes beyond just errors.
- 15:35You'll learn where your users are getting stuck.
- 15:37LogRocket intelligently surfaces the key moments of user frustration showing you how to improve your site.
- 15:43And LogRocket works with your stack regardless of the language or framework you're using.
- 15:46And they even provide SDKs for popular front-end technologies like Vue.js, React.js, and more.
- 15:51Do you already use systems such as Rollbar?
- 15:54Well, you're in luck because they integrate seamlessly with Rollbar and others for great visibility of front-end and back-end errors.
- 16:00Understand the cause of every bug and customer issue today.
- 16:03Visit talkpython.fm/LogRocket to get started with their free tier.
- 16:09Let's look a little bit inside at what you guys are working with, some of the libraries and stuff.
- 16:14I 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:22So could you give us just a quick flyover of some of the tools you're using?
- 16:25A 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:39I've been doing a lot of that with just plain jQuery, but I'm slowly moving to React for my front-end framework.
- 16:45But for the back-end, I prefer to use Python Flask with gevent and SQLAlchemy as the database interface.
- 16:54And 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:03We also use a message bus system as our interconnection between processes.
- 17:10So 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:20So all of the database access is sort of hidden away.
- 17:24There used to be a lot of like per max, not good, and we're moving away from that.
- 17:31And then we use like we use RabbitMQ as a database as a message system.
- 17:36We 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:42So we have a lot of twisted code.
- 17:44We use twisted code for asynchronous work.
- 17:47We also use a lot of gevent for the same thing.
- 17:49I 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:03Like 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:14So asynchronous code is really handy for that.
- 18:16So you can set something.
- 18:16You 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:24So to be able to handle essentially thousands and thousands of those state-driven processes is really handy.
- 18:33That's really cool because if you tried to just wait for that response, that would be a problem.
- 18:39Oh, yeah.
- 18:39If you wait for an hour, this Flask server just won't scale.
- 18:45You know, I mean, we set the time on it.
- 18:46I'd have a bunch of production lead guys in my office stamping their feet in a heartbeat if that was the case.
- 18:51How interesting.
- 18:52When you talk about doing asynchronous stuff with Flask, is that using, say, gevent on Flask?
- 18:58Or are you doing, like, architecture that has queues?
- 19:02Well, we have a couple things.
- 19:04I use gevent in Flask to try to make that as – add asynchronous behavior to that.
- 19:10It's still – because of the database access, it still can get paused on a database call.
- 19:15That's one of the reasons why we are moving to – the data access is going to another process.
- 19:21So that other process now becomes – you know, it's handled – there's multiples of those.
- 19:26And it handles the database.
- 19:28But my call from my application or any other application can be asynchronous to that.
- 19:33It's no longer waiting because it's – now it's going to get a call back when it's done.
- 19:36Yeah, that's really cool.
- 19:37And it just queues up on that other system probably.
- 19:40It won't time out, for example, and things like that, right?
- 19:43Yeah, those other systems are all also entirely asynchronous.
- 19:46So 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:50And those come across the message bus as an event.
- 19:54I 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:01You're here working with latencies in the minutes or hours.
- 20:05So you might choose a really different architecture, whereas people say, well, the database is kind of slow.
- 20:11It takes 30 milliseconds to get back to us and we want to go scaling.
- 20:1330 milliseconds, I laugh at that.
- 20:15I'll just use an – it'd be like an ASICIO event loop or something like that.
- 20:21That would be fine for that, right?
- 20:23So quite interesting to think about.
- 20:26So that's the backend stuff.
- 20:27I 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:37But have you looked at Quart?
- 20:39I 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:53I mean it just – it provides a lot of features that I don't use.
- 20:56Like I don't do any web form validation.
- 20:58I'm doing all either WebSocket or AJAX calls, REST APIs.
- 21:05So I don't do a lot of form validation.
- 21:06I don't serve a lot of files.
- 21:08I'm mostly creating REST APIs.
- 21:11So I just want to make that part faster, and those things that you mentioned would do that.
- 21:18So I'm looking into that to take better advantage of the system.
- 21:21Yeah, that makes a lot of sense.
- 21:23And there is a lot of stuff in these web frameworks that you just don't need if the response is Flask.jsonify.
- 21:29For my case, I don't even serve up the web pages, the front end anymore myself.
- 21:34That's done by a dedicated web server.
- 21:36So my application is strictly – has turned into a REST API.
- 21:42That's a really interesting place for people to work who want to work on the web, but they are not designers.
- 21:48Yeah.
- 21:49Right?
- 21:49They 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:56There's still some really interesting and challenging programming to be done building this back-end layer, I think.
- 22:02Yeah, I absolutely agree.
- 22:03I am currently working on this gigantic project, which is this REST API that drives a big part of our business.
- 22:11And 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:20I 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:26But also, I really enjoy the GUI part.
- 22:29I used to be a – for a short time, I was a Windows developer.
- 22:33And 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:41And they often thwart me, but –
- 22:44Yeah.
- 22:44What –
- 22:45Hey, we'll try.
- 22:47What frameworks did you use to build GUI?
- 22:49Well, that was way back in the day.
- 22:51I was using Windows 32, the raw Windows 32 API.
- 22:55So it was a nightmare.
- 22:56Oh, so you were down at the Charles Petzl Win32 layer, huh?
- 23:00Oh, yeah.
- 23:01Wow.
- 23:01That's no VB.
- 23:02Yeah, you don't mess around.
- 23:03You go straight to a simulated learn programming.
- 23:05You go to, like, the Win32 API to do GUIs.
- 23:08That's awesome.
- 23:09Okay.
- 23:09So 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:17Yeah, there's a couple groups.
- 23:18There'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:33Right, talking to stuff like the API tree building.
- 23:36So how do you decide upon React?
- 23:39I mean, I actually am still a bit of a fan of jQuery.
- 23:41I just want, like, a little tiny bit of interaction.
- 23:44Like, jQuery actually is not too bad.
- 23:46It doesn't have all this setup.
- 23:47Set the apps.
- 23:48Set the models.
- 23:49I mean, if you're building real apps, then React and all these things are cool.
- 23:53But I still have some love for jQuery.
- 23:55But tell me about why you chose React.
- 23:57Well, 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:06And I'll have to send you a link to that because I still like that.
- 24:11Yeah, yeah, we'll put it in the show notes.
- 24:12Because it's one of the reasons I like it.
- 24:14It's quick.
- 24:14You can get a prototype up and running very fast.
- 24:17And 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:25But React was – I was actually going down the path of Angular.
- 24:29And then, you know, we sort of switched gears and I jumped on React.
- 24:33And, well, anybody who's done this kind of work probably has come from another – who's come from another world.
- 24:39You know, you wait five minutes in the JavaScript world and there's another framework out there.
- 24:42It took me a long time to actually jump on board.
- 24:46But I like the conceptual nature of – or the concept behind React where you have components that you can glue together.
- 24:53And those components can have a visual and a behavior aspect to them.
- 24:59Yeah, it's almost like the control programming model of, like, the older Windows systems and stuff.
- 25:04Where you can – you know, I'm going to buy a grid control and I drop it here and now it does grid stuff.
- 25:08That 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:17And then I'm sort of, you know, I'm bolting behavior to it with a –
- 25:22It is non-obvious where that behavior comes from in jQuery.
- 25:24It's like I know it's hooking an event somewhere and I cannot figure that out.
- 25:27Well, I've written some really huge jQuery applications and they're still being used.
- 25:33And whenever anybody wants to add features to that, I'm, like, cringing.
- 25:36I'm like, oh, no, please no.
- 25:37Because there's so many side effects and ripples when you change things.
- 25:42So it gets to riddle after a while.
- 25:44I just reorganized it.
- 25:45I put inside this div and it just stopped working.
- 25:47Thanks.
- 25:48I know.
- 25:49I know.
- 25:49Thanks for that.
- 25:50Let's not do that.
- 25:52But React seems more – I mean, I like the module system so that you can actually break it.
- 25:57I like JavaScript.
- 26:02And to me, in many ways, I know people don't like JavaScript who come from other languages.
- 26:08But 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:15And now that things like React and Angular, React in particular, has these idea of web components that have look and feel and behavior,
- 26:25that feels like a real way to program a GUI, especially –
- 26:30Yeah.
- 26:31Yeah.
- 26:32It looks like a web platform as an application platform to deliver stuff.
- 26:36Yeah.
- 26:36That's interesting.
- 26:37Have you thought about writing any desktop apps with, say, Electron.js?
- 26:43I have.
- 26:43I'm looking into that using – in my case, because I'm trying to get smarter on React, I'm thinking of React Native.
- 26:50But I've seen some stuff written in Electron, and it's all very interesting.
- 26:54And I want to get there because I like that stuff.
- 26:56It's really interesting.
- 26:57I wish it had an option for a Python backend.
- 27:00Yeah.
- 27:00And I just discovered – one of the listeners from the Python Bytes podcast sent me this thing.
- 27:06It's more of a way to work with Electron that has a Python backend instead of Node.js.
- 27:12Oh, neat.
- 27:13And you get it – install it natively on the system.
- 27:16It's called Python Electron.
- 27:18Yeah.
- 27:18I'll put that in the show notes.
- 27:19I wish it was called Proton because Electron, Proton, Python.
- 27:22But a name is missed here.
- 27:25But it's really quite interesting.
- 27:28And I think you could take React and the JavaScript and HTML and pair that with this Electron Python backend.
- 27:35It would be very smart.
- 27:35Oh, I think that would be great because I've written wxPython applications, which is a lot of fun.
- 27:43It reminds me a lot of my Windows programming days.
- 27:45And they're really cool, but they're so hard to port.
- 27:48They'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:54Right.
- 27:55Make sure you have Python 3.4.
- 27:57And then you're going to need to do this.
- 27:59And then you've got to pip it like, whoa, this is not how I get an app.
- 28:01I get it from the app store or something.
- 28:02And then if actually somebody adopts it, any kind of update process to put changes out there is almost impossibly painful.
- 28:11Yeah.
- 28:12Yeah, yeah.
- 28:13So this Electron Python would have its own auto-updating system and stuff.
- 28:16It would be really neat.
- 28:17And you package it all up and it's .app or .exe.
- 28:20Yeah, that would be nice.
- 28:21I'll have to dig into that.
- 28:22I'm looking forward to that.
- 28:23Yeah, yeah.
- 28:24I'll put a link.
- 28:25Cool.
- 28:25Thank you.
- 28:26Yeah, 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:34Although I don't have any intention to do tons of rich front-end work right now.
- 28:38But, yeah, there's a lot of good choices.
- 28:40But like you said, by the time this episode ships, there's going to be another one.
- 28:44Well, a lot of the stuff I wrote was a whole combination of jQuery plugins.
- 28:48I used jQuery, jQuery UI, data tables.
- 28:52I used handlebars a lot to do templates within jQuery and HTML.
- 28:57So it was a whole pile of stuff.
- 28:59But it gets to be difficult to make the apps look consistent, one app to the next.
- 29:05That gets to be hard to manage.
- 29:06Yeah.
- 29:07Maybe I'll have to check out React.
- 29:08It sounds pretty good.
- 29:09I think you'll like it.
- 29:10I know Angular.
- 29:12I was working with Angular, and I really liked that.
- 29:14One of the big concepts with Angular is it feels like they're trying to add functionality to HTML.
- 29:20And one of the differences I see with React is it's the exact opposite.
- 29:24They're trying to add HTML to functionality.
- 29:26So it's like embedding HTML into JavaScript.
- 29:28Conceptually, it's a little different.
- 29:30But one of the things I had trouble with was in Angular, it's sort of dependent on TypeScript, which I really like TypeScript.
- 29:37But 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:46Yeah.
- 29:48TypeScript is interesting.
- 29:49It has a lot of parallels back to the type annotations in Python 3.
- 29:54But TypeScript, one of the things I'm not a fan of with TypeScript is it's a little more serious about the types.
- 30:02Python is like, these types are here to help you.
- 30:05If they get in the way, you can kind of just pretend they're not there.
- 30:08Whereas TypeScript, it's like, no, you haven't declared this variable type that's in another file.
- 30:13You know, it really is.
- 30:14It can be a thing.
- 30:15It gets to start to feel like C or Java in that way, that it's very strict typing.
- 30:19Yeah, it really is.
- 30:21But there's a lot of potential, a lot of potential with types, especially in the Python stuff.
- 30:26We have Cython now understanding Python 3 types.
- 30:29And then Dropbox is now talking about mypyc, which will take type annotated Python and compile it to C code.
- 30:36I think that you guys mentioned that on either Talk Python To Me or in Python Bytes, you mentioned that at one time.
- 30:41Yeah.
- 30:42Yeah, I think in Python Bytes we did.
- 30:43Yeah, that's really new.
- 30:45And I think that's quite interesting.
- 30:46Yes, absolutely.
- 30:47So I think that leads into another area that you are passionate about is talking about whether it's Python, is it slow?
- 30:55Does it perform well?
- 30:56Is it going to solve your problems, right?
- 30:58Like how do you measure performance anyway?
- 31:00Well, that's the thing.
- 31:01I mean, people, you know, from my embedded days, I know I'm a speed freak.
- 31:05I want this thing to go as fast as possible.
- 31:07You started out in assembly, right?
- 31:09I mean, come on.
- 31:10Yeah, right.
- 31:10Every cycle counts on these little tiny machines.
- 31:14But I'm a big believer in there's no sense in optimizing unless you measure.
- 31:18And the other part of that is you have to have a target.
- 31:21Like what does fast mean to you?
- 31:23How fast does this have to be?
- 31:25And why?
- 31:26Why do you need it to be fast?
- 31:28I 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:41It'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:49I've seen that happen plenty.
- 31:51It'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:59But it's no, no, no.
- 32:02You should have used a set instead of a list here.
- 32:04Or something entirely trivial and it's just you would know if you had looks.
- 32:10And if you're building a 24-7 server, that thing has a long life.
- 32:16So there's lots of opportunities where things don't – they get called once an hour, once a day.
- 32:20It's not that big a deal.
- 32:23And it's very important to say, okay, where is this thing spending most of its time?
- 32:27Is it busy?
- 32:27And in my world today, there's lots – like I said, there's events that are minutes, hours apart.
- 32:32So I need to pay attention to what matters.
- 32:36Right, 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:44Because you could write – even in Python, you could write some obtuse code and I don't really want to read that again.
- 32:50Oh, yeah.
- 32:51And the other thing is that computers are so fast.
- 32:54I mean it's long – we long since passed the tipping point where the computer's cycle time is more expensive than mine.
- 33:03My cycle time is much more expensive.
- 33:05In fact, my cycle rate is very slow.
- 33:07So being able to develop code quickly is really important.
- 33:11It's important.
- 33:12You're absolutely right.
- 33:13I totally agree with you on what are we optimizing for.
- 33:15Are we optimizing for the computer or for the business or the project or the product or whatever it is, right?
- 33:22Like if you can add two more features to your website a month but you pay an extra $20 in hosting, who cares?
- 33:32Yeah, exactly.
- 33:32Right?
- 33:34Yeah, 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:47Right.
- 33:47Or say, forget it.
- 33:48We're going to go.
- 33:49Or forget it.
- 33:50We're going to write it and see.
- 33:52I think there's a couple of interesting options there.
- 33:54One, you say you need to measure and see what's working.
- 33:56Like 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:05Yeah, exactly.
- 34:06Something crazy like that.
- 34:07And just a tiny bit and not have to completely re, you know, throw the baby out with the bad boy sort of thing.
- 34:12Oh, I often find that idea of adding like the optimization flag to see gives you like really incremental improvements versus doing algorithmic optimization.
- 34:22Like I'm improving the algorithm.
- 34:23My data structure is better where you get orders of magnitude improvement in speed.
- 34:29Yeah, yeah, you choose the wrong data structure, not just the algorithm, even just the wrong data structure.
- 34:33And it could be a thousand times slower because you said, well, I always put stuff in a list.
- 34:37But really what I wanted was a dictionary because I'm randomly looking up stuff.
- 34:41I'm not looking it up by index.
- 34:42Right, exactly.
- 34:42Yeah, pretty interesting.
- 34:44This portion of Talk Python To Me is brought to you by Rollbar.
- 34:50Got a question for you.
- 34:52Have you been outsourcing your bug discovery to your users?
- 34:54Have you been making them send you bug reports?
- 34:57You know, there's two problems with that.
- 34:59You can't discover all the bugs this way.
- 35:01And some users don't bother reporting bugs at all.
- 35:03They just leave, sometimes forever.
- 35:05The best software teams practice proactive error monitoring.
- 35:09They 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:17Teams from companies like Twilio, Instacart, and CircleCI use Rollbar to do this.
- 35:22With Rollbar, you get a real-time feed of all the errors.
- 35:27So you know exactly what's broken in production.
- 35:28And 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:36If you aren't using Rollbar yet, they have a special offer for you, and it's really awesome.
- 35:40Sign up and install Rollbar at talkpython.fm/Rollbar.
- 35:45And 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:56Get notified of errors in real time and make a difference in Open Source.
- 36:00Visit talkpython.fm/Rollbar today.
- 36:04Another thing that you spoke about was that you're not the youngest programmer.
- 36:09You said you started out in the 80s, right?
- 36:11And this is something I'm passionate about because running the podcast, people reach out to me a lot and say,
- 36:16Michael, I'm 40.
- 36:17It's too late for me.
- 36:18I can't do any of this programming stuff.
- 36:20Like, programming is for young folks.
- 36:22I myself am, you know, not especially young.
- 36:25But I see the programming space as quite vibrant for people.
- 36:28I teach at this STEM school, STEM education place near me, and I teach programming Python to kids there.
- 36:35And I've written some material there.
- 36:36And I've been trying to – I've been twisting the guy who runs the place.
- 36:40I've been twisting his arm to think about that he really needs – he really should market to older adults
- 36:46because I think that this is – you know, like they say, like, crossword puzzles is a good way to keep your mind sharp.
- 36:52I think this is, like, the greatest crossword puzzle ever is kind of programming.
- 36:55Yes.
- 36:56And it's –
- 36:56It absolutely is.
- 36:57It's so engaging and you have to think deeply.
- 37:01It's better than video games.
- 37:04It's certainly better than Sudoku.
- 37:06Oh, yeah.
- 37:08Yeah, absolutely.
- 37:09And it's – with languages like Python and, you know, some of the other modern scripting languages, it's so accessible.
- 37:15There's no – there's no, you know, the whole – I would never want to.
- 37:19I mean, I really considered myself a very strong C++ programmer.
- 37:23But 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:31Remember the times when the header and the .lib file would get out of sync?
- 37:35Yes.
- 37:35And it would just not – you're like, why is this just crashing randomly?
- 37:39Like, I don't even understand.
- 37:40Like, so glad that problem's gone.
- 37:41Oh, yeah, me too.
- 37:42I don't want to – I mean, I like that stuff, but I don't want to go back there.
- 37:45Yeah, for sure.
- 37:46I think this is a really interesting idea of having a programming class for older adults.
- 37:51You know, Philip Guo, who was at UCSD, I had him on Talk Python a while ago about programming in your golden years.
- 38:00And said a lot of folks who were starting to retire and were learning programming actually were doing so to connect with their grandchildren.
- 38:08Because their grandchildren were in Minecraft or they wanted to do, like, robots.
- 38:12And they're like, well, I'd like to do that with them.
- 38:14Apparently, that requires programming like JavaScript and Python.
- 38:17So I'm learning it, right?
- 38:18Yeah.
- 38:19I had taught – this is a stupid story.
- 38:21But years ago, I had taught a couple of adult ed classes to help people get into Windows and DOS.
- 38:27This is how far back it goes.
- 38:28And I would be up there.
- 38:29You know, I'd be talking.
- 38:30I would be talking about something.
- 38:31And it invariably would happen.
- 38:33I would say, okay, I want you to enter this command.
- 38:35And I'd turn to the whiteboard and I'd write on the whiteboard.
- 38:38And behind me, I'd hear this beep, beep, as people were restarting their computers because they had typed something wrong.
- 38:44Oh, my God.
- 38:47Because they were so afraid of getting it wrong.
- 38:49I'm like, no, you can't hurt it.
- 38:50Just go with it.
- 38:51Yeah.
- 38:52Unless you write format, you know, C colon slash Y or something, you're going to be fine.
- 38:57You're okay.
- 38:59And 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:11But I had to learn new languages.
- 39:12So I committed to this sort of constant learning idea early.
- 39:16And I've stayed with it my whole career.
- 39:19And it's really paid off because I'm still able to learn new things.
- 39:24I'm learning new things all the time.
- 39:25It works like I'm learning React, for instance.
- 39:27And a little bit of Erlang, for crying out loud.
- 39:29Wow.
- 39:30But 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:42And, you know, mentor people based on my experience and able to learn from people.
- 39:48So I hope that I'm not overbearing about that.
- 39:51But 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:57But they have a valuable skill that I want to learn and know about.
- 40:01Yeah, absolutely.
- 40:01Do 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:10Yeah.
- 40:11When I moved into software development full-time from – it was the same company I was doing the process controller work.
- 40:17I moved to their software group.
- 40:19And all those guys had MSs and doctorates in computer science.
- 40:23And so I was playing catch-up all the time on Fortran and C programming.
- 40:28And so I worked really hard.
- 40:30One of the things I did, my boss was a very sharp guy.
- 40:32And I would hit a problem.
- 40:34You 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:40The deal was – and I would try to make it so he didn't answer the question within one minute.
- 40:45And I – in five years, I failed every time.
- 40:48He would – but at least, you know, I did the work to ask intelligent questions to get there.
- 40:54Yeah.
- 40:54That's a really good point.
- 40:56You know, I'm also more or less a self-taught programmer.
- 40:59I took, you know, a couple of programming classes, C++, Fortran in college and stuff.
- 41:05But for the most part, I studied math.
- 41:07And 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:17Well, I didn't take the operating system class.
- 41:19I don't know maybe as well as that person, right?
- 41:20But I know that I taught myself all of this programming stuff.
- 41:26And there's basically nothing that scares me.
- 41:29Right.
- 41:29Well, not nothing.
- 41:29But not much that scares me because it's like, well, I've come this far by forcing myself to do it.
- 41:36And 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:44And so I know to get to wherever you want to be, it's like just more steps.
- 41:47Absolutely.
- 41:48And those two things, they drive me pretty hard to constantly learn stuff that I don't know.
- 41:53But I also know myself.
- 41:55I'm an applications engineer.
- 41:57I need to apply this stuff.
- 41:59So, you know, red, black trees and that kind of, you know, AVL automatic balancing stuff is like – I mean, yeah, okay.
- 42:06I'm just going to throw a dictionary at that.
- 42:07It solves the problem.
- 42:08Yeah.
- 42:10So there's gaps in my knowledge that I don't have.
- 42:12But on the other hand, I haven't run into too many cases in a long career where I've really needed that stuff.
- 42:17So for me, I just – I need to know the stuff that is applicable to my job.
- 42:21Yeah.
- 42:22You know, a lot of people who take computer science have to do things like calculus and differential equations and stuff.
- 42:27I don't know many programmers who still do differential equations.
- 42:30I know there are some.
- 42:31Yeah.
- 42:31But not most of them, right?
- 42:33Most of it, it's like, well, algebra, maybe a little geometry, maybe.
- 42:36Well, sometimes I make this joke at work all the time.
- 42:39Like they often lean on math teachers to be the computer teachers at schools.
- 42:45And I'm like, yeah, I don't know if that's the right choice.
- 42:47Sometimes I think it should be English majors because most of my life is tearing apart strings all day.
- 42:53That's true.
- 42:55It is a lot of text, isn't it?
- 42:57It's a lot of text.
- 42:58So, 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:03Because, like I said, that's how I got to know you.
- 43:05You said a big part of your day-to-day work is working on these REST APIs with Flask.
- 43:10And you wrote a couple articles on realpython.com about connection with an X for REST APIs.
- 43:18Do 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:23Yeah.
- 43:23I 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:33I was looking for ways to make that nicer, make that cleaner.
- 43:36And actually, another guy introduced me to Connexion.
- 43:40And that is a really nice tool.
- 43:43It does two things that I really like.
- 43:45Besides 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:55So, 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:04Because 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:10And 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:21And Swagger, or excuse me, Connexion helps you think about that in, I think, much clearer ways and structure the system.
- 44:29Plus, whenever I've shown off, whenever I show off my stuff and I show the Swagger UI, everybody's really impressed.
- 44:37It'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:49And that's been very powerful.
- 44:52Yeah, the documentation is really cool, actually.
- 44:54Yeah, it's fantastic.
- 44:56Because, you know, I definitely prefer the REST APIs over other options that have been popular, like SOAP services and stuff.
- 45:04But 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:11Whereas, 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:20And so Swagger gives you a nice view over top of that, right?
- 45:24Yeah, a really very nice, you know, a consistent standardized UI.
- 45:29I mean, they're constantly reproving it to interact with the API once you get it up and running.
- 45:34And 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:44But 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:02And that's really powerful.
- 46:03Yeah, nice.
- 46:04So you have this Swagger YAML file that defines the API basically and generates the help.
- 46:08How do you get the, like, where does connection and your code all fit together?
- 46:14Well, I know how to write a general, like a normal Flask API.
- 46:19I would put at route and I would return Flask.jsonify.
- 46:22But what do I do in this connection on the world?
- 46:24Well, if you start configuration, the handshake point, the connection point between the configuration and the code, there's one specific parameter.
- 46:33I think it's, what is it?
- 46:35Object ID or something like that.
- 46:38It'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:48So you might have, you know, it's just a string.
- 46:50It'd be like my code dot my app dot my method within that app.
- 46:56And Connection is smart enough to actually introspect your code and find that.
- 47:02You 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:11It will create that within Flask to handle that URL when that gets called.
- 47:16So it's a very nice way.
- 47:18I see.
- 47:19You know, it auto connects that, this piece, the configuration piece with the code that's going to handle that configuration.
- 47:26Oh, that's cool.
- 47:26So it finds the Python files and implement it and sort of does the connection for you.
- 47:30Yeah.
- 47:30I guess it's the name.
- 47:31And it tells you, you know, it tells you if you don't have one.
- 47:33Like I've often misspelled things and it'll tell you, nope, that doesn't exist.
- 47:37No connection there.
- 47:38Yeah, too bad.
- 47:40Okay, this looks really nice.
- 47:41So you have a couple of nice articles on that and people can look through there.
- 47:46Yeah, on RealPython I've published some articles, two articles actually, on this REST, this FlaskConnection REST API.
- 47:52The first one was just an in-memory structure that I wanted to talk.
- 47:56It 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:03It's just a convention.
- 48:03And 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:12So I took the basic API and code and then added a database connection through SQLAlchemy using SQLite as the database.
- 48:21Yeah, that's the way to do it.
- 48:22Very nice.
- 48:23I love SQLAlchemy.
- 48:24Oh, it's terrific.
- 48:24I'm not a big SQL guy, so I like that Pythonic way of thinking about it.
- 48:29Yes, I'm with you on that.
- 48:31So that was on RealPython.
- 48:34You also did some on dbader.org, which is kind of similar because Dan Bader runs both sites.
- 48:42Yeah, he runs both sites, right.
- 48:43So it's a little bit of a connection there.
- 48:46You did one on just sort of Python, getting started with Python.
- 48:50But one I thought was pretty interesting.
- 48:51I actually used this as a little bit of research for my recent async course.
- 48:55Yeah, I was very happy to see that.
- 48:56Yeah, the one's called Understanding Async Programming in Python.
- 49:00Yeah, I had maybe 10 or 15 articles I read to just see what people were doing.
- 49:04And this is a nice one.
- 49:06And 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:13Yeah, this was an article that actually came out of a presentation I gave at one of the Shutterfly All Hands meetings.
- 49:20And I had been in touch with Dan about the first article, just the Python introduction.
- 49:26And then he and I talked, and he was interested in this asynchronous one.
- 49:30And I put that together.
- 49:31It's a passion of mine because I like this whole asynchronous way of thinking.
- 49:36I've written threaded code in C and C++ and lived to regret it.
- 49:41And 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:56And 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:07And there's just like this real hurdle to get over for people to get their heads around it.
- 50:12And it's interesting to me because in reality, humans are asynchronous.
- 50:17Our behavior is asynchronous all the time.
- 50:19But to think about it in this linear presentation of code, it's kind of hard to break out of that linear execution model.
- 50:28But 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:38Exactly.
- 50:39You 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:49And yeah, it doesn't make any sense, right?
- 50:51The real world definitely is asynchronous.
- 50:53Oh, yeah.
- 50:54I like the polling parent one where you're running back and forth checking every two minutes on everything that's going on.
- 50:59Is the dinner ready?
- 51:01Is the kid getting ready?
- 51:03Is the laundry – is the washing machine done?
- 51:05No?
- 51:05Yes?
- 51:06No, no?
- 51:06How interesting.
- 51:07Yeah, so this is a cool one.
- 51:09I 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:16That'd be fun.
- 51:17Yeah, 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:25I 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:35And I like it that it's native to Python now, the async stuff.
- 51:40Yeah, and especially the async and await keywords.
- 51:46Like 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:56I think it's hard because you have to unravel or turn your code inside out.
- 52:00I'm going to start this and then it's going to call this other thing to continue it and so on.
- 52:04But 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:10Yeah, it's great.
- 52:10And it's beautiful.
- 52:11I love it.
- 52:12It's really, really nice.
- 52:13I've talked to some of my friends who are like the front-end guys I work with who are friends of mine.
- 52:18You know, they're used to this whole asynchronous method in JavaScript.
- 52:21But 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:31And it's one of the things I like about React is it helps you break out of that.
- 52:35Yeah, that is really nice.
- 52:36Yeah, that deeply indented callback stuff.
- 52:38It's just hard to deal with if something goes wrong.
- 52:41It's like, well, where do I unravel this to?
- 52:43Yeah.
- 52:44I'm halfway down this hole and I don't know where to go from.
- 52:46What am I doing now?
- 52:48Yeah, this is the problem.
- 52:50So you've got to take your step back each level out.
- 52:52But, yeah, I'll put that in the show notes.
- 52:54People will definitely enjoy that.
- 52:56So we're down to just a few minutes, a time left.
- 52:59So I suppose I'll ask you the two questions here at the end.
- 53:03All right.
- 53:03So if you're going to write some Python code, what editor do you use?
- 53:06Well, currently I'm an IntelliJ editor user and with the Python module plug-in.
- 53:12I 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:19Sometimes I have to do code reviews in Java and look at JavaScript and some other things.
- 53:24Right.
- 53:25So IntelliJ is really great.
- 53:27I don't understand people who don't want to use an IDE with a debugger.
- 53:31I just don't get it.
- 53:33Yeah.
- 53:35You and me both.
- 53:36I'm such a fan of it as well.
- 53:38I think it's really great.
- 53:39So 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:47The faster you type, it will start to shoot flames and sparks from your code as you type.
- 53:52So if you need to do a presentation show off, you plug that in and take it to the next level.
- 53:57It's, of course, completely silly but fun.
- 53:59I 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:10A lot of programmers don't, but I type pretty quick, so I'll definitely try that out.
- 54:14Yeah, all fun with that.
- 54:15Definitely for presentations.
- 54:16All right.
- 54:17So notable PyPI packages?
- 54:18Well, I really like, as I mentioned, Connexion, which is this REST API.
- 54:22And 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:37Right.
- 54:38If you try to return it out of your method, it'll freak out and go, I cannot serialize this thing to JSON.
- 54:42Yeah, there's no matching thing for a Python date-time object in JSON.
- 54:48So this Marshmallow thing allows you to, just as you would in SQLAlchemy, build a model that matches your table structure.
- 54:55Marshmallow 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:07That is cool.
- 55:09And back and forth.
- 55:09It does both.
- 55:09Yeah, that's really cool.
- 55:10I should definitely learn about Marshmallow.
- 55:12Oh, it's sweet.
- 55:13It has the same thing as SQLAlchemy, where you have relationships, the one-to-many, many-to-many relationships in the data table.
- 55:20You 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:29Marshmallow will take care of that as well.
- 55:31It'll just go down the tree and serialize them all.
- 55:35That just does the whole object graph.
- 55:36Wow.
- 55:37Yeah.
- 55:37Very nice.
- 55:37You 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:44Okay.
- 55:45I'm loving this one.
- 55:46Good choice.
- 55:47All right.
- 55:49Well, this – yeah.
- 55:50This has been really interesting.
- 55:51I really appreciate you being on the show, Doug.
- 55:53Oh, I'm very glad to be here.
- 55:55It's great.
- 55:55I've really enjoyed it myself.
- 55:56Yeah, absolutely.
- 55:57You got a bunch of recommendations, and I think a really interesting way to look at that whole async programming thing.
- 56:02So I'm looking forward to your follow-up articles that you write about this.
- 56:05Yeah, definitely be fun.
- 56:07I 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:14Yeah, it's definitely fun.
- 56:15Yeah, we don't need to do crossword puzzles or Sudoku.
- 56:18We can just work on our threaded code, right?
- 56:20Yeah, right.
- 56:21In my classes, I teach the kids using the turtle module because I get them right into drawing on the screen.
- 56:28I do the same thing with adults.
- 56:30It would be great, I think.
- 56:31Yeah, absolutely.
- 56:31It would.
- 56:32All right.
- 56:33Well, thanks for being here.
- 56:34Good to talk to you.
- 56:34Thank you, Michael.
- 56:35Bye.
- 56:36Bye-bye.
- 56:36Bye-bye.
- 56:37Bye-bye.
- 56:37This has been another episode of Talk Python To Me.
- 56:40Our guest on this episode has been Doug Farrell, and it's been brought to you by LogRocket and Rollbar.
- 56:46LogRocket will help you avoid the back and forth, helping your users with problems on your site.
- 56:51Visit 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:00Rollbar takes the pain out of errors.
- 57:03They 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:10Track a ridiculous number of errors for free as Talk Python To Me listeners at talkpython.fm/rollbar.
- 57:18Want to level up your Python?
- 57:19If you're just getting started, try my Python jumpstart by building 10 apps or our brand new 100 days of code in Python.
- 57:26And if you're interested in more than one course, be sure to check out the Everything Bundle.
- 57:30It's like a subscription that never expires.
- 57:32Be sure to subscribe to the show.
- 57:34Open your favorite podcatcher and search for Python.
- 57:37We should be right at the top.
- 57:38You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 57:47This is your host, Michael Kennedy.
- 57:49Thanks so much for listening.
- 57:50I really appreciate it.
- 57:51Now get out there and write some Python code.
- 57:53I'll see you next time.