Django Chat

Django the Good Parts - James Bennett

Episode Summary

James is an original core contributor and longtime pillar of the Django community. We discuss Django’s early years, what it got right (and wrong), how the community developed, and the current state of web development with Django.

Episode Notes

Support the Show

This podcast does not have any ads or sponsors. To support the show, please consider purchasing a book, signing up for Button, or reading the Django News newsletter.

Episode Transcription

Carlton Gibson 0:05
Hi, welcome to another episode of Django Chat, a fortnightly podcasts on the Django web framework. I'm Carlton Gibson joined by Will Vincent. Hello Will!

Will Vincent 0:12
Hi, Carlton.

Carlton Gibson 0:14
Hello Will. And this week we've got with us James Bennett, who's longtime Django contributor been on the Django board and well, you know, all round hero of mine, that James, thank you for coming on. It's really

James Bennett 0:25
Hello, thanks for having me on

Carlton Gibson 0:26
It's a massive honor to have you. We always talk about to start off with, like people's backstory and how they, how they got into programming, how they're going to Django and all the rest. But am I right in thinking that you did philosophy? Because I did philosophy? Yes, yes.

Will Vincent 0:43
But you failed. You didn't get a PhD like Carleton, you've so quit early. I was

James Bennett 0:47
trying to I was a terrible student. So I did not get into a Ph. D. program. Oh, I didn't know that. So I was growing up, my family didn't have a lot. I didn't actually have a computer at all. Like I had a little bit of experience with an apple two at school. But it wasn't until I went off to college that I hadn't reliable access to a computer and to the internet. I didn't have my own computer until my second year. And I was taking courses with a small college. And so as a department, not just a philosophy, but a combined department of religion, philosophy, theology. Okay. I was taking a course on ancient Hellenistic religions. Nice.

Will Vincent 1:39
Well, Carlton, No, I never did

James Bennett 1:41
that, sir. Yeah, the professor was kind of a kind of a geek. And at the end of the course, gave us an option, you could either write a 15 page research paper on an assigned topic or produce a website with five pages.

Carlton Gibson 1:59
That's easy. I was always a good programmer.

James Bennett 2:03
So I learned a little bit of HTML, made a website and kind of was interested decided to start learning a little more, learn some HTML, some CSS and JavaScript. I was working as sort of a department assistant, I was the guy who would go like when they needed something from the library, I would go pick it up for them, or they needed copies made of things. And my advisor, found out that I learned how to do this. And I was like, Hey, are departments website could use a little refresh? Would you like to do that, and we'll pay you for it. And so I did. And then I did his personal faculty page for him. And that was kind of the start, I spent a summer when I was supposed to be doing much more research than I actually did learning PHP and a couple other things. build my own, like personal blog engine. And then I graduated, applied to some PhD programs didn't get into any got kind of a boring job at an insurance company, and saved up a little money. And then went into business with a friend of mine who was a designer, because you could do that this was like 2004 2005, you could do that back then you could just say, I'm going to go into web stuff. And it would work and started doing contract work, mostly PHP and Perl. And I was learning Ruby and Rails. Shortly after that came out. I bought the rails book. I had learned Python from reading dive into Python, by Mark pilgrim. But at the time, Python web development was basically Zope. Right? Yeah. And where I was living, I was living in Virginia. There were people around me like there were user groups that I could go to for tech stuff that some of them did Python, but they all did government contracting. So like US federal government websites, with Zope, and like hugely complex requirements and everything. And then one day, this thing called Django came out. And I read about it, I decided to play with it. And I really liked it. And I remember I wrote something on my blog, not the one that I have now, but an older one that thankfully, is about how I really liked it. I really liked this Django thing. And I really wish one of my clients would let me use it. And I kind of joked about maybe I should go on strike until somebody says I can use Django. And well, after that, I got a message from Jacob Kaplan moss saying, hey, the journal world is hiring. Would you like to apply?

Carlton Gibson 4:51
Fantastic,

James Bennett 4:53
until I did, flew up to Kansas. interviewed with them, they decided to hire me And so I moved out there and that started my like proper Django that's

Carlton Gibson 5:05
right in the crucible that's like, you know, you're there.

James Bennett 5:10
Yeah. So one fun thing that that little website that I did for that course. Thankfully, that also is not online anymore. But for a long time it was and because it was on a.edu domain, I kept getting email from people assuming I was an academic expert on the topic and being like, you know, I've been reading this can you offer any follow ups and anything else that I should study?

Carlton Gibson 5:33
Cuz you were like the web most pressing the button? Yeah, I

James Bennett 5:36
was. I was not a professor when I did that I never am going to be. I was a student who was lazy and tried to avoid writing a 15 page paper.

Will Vincent 5:47
So is it fair to say that programming seemed to fit your mind though? I mean, I don't hear quite the same struggle that multiple other people seem to have like learning multiple languages, it seems like you obviously had to do the work, but it made a sense to your mind. programming works.

James Bennett 6:05
Python did. Python has always fit my brain. PHP and Perl. To put in some work JavaScript, I had to put in some work HTML kind of clicked easily. But that was the age of view source. We're not gonna do that anymore. No. I mean, it's also the I just had, thankfully, because I was doing it over a summer, when I had not many other responsibilities, I had the time to just kind of like, bang my head against it. Like, my first little PHP blogging application was not good. But I was very proud of it.

Will Vincent 6:41
Yeah. That's always how it is, right? I mean, any. Even I was telling someone the other day, like, you look at code from a year ago that, you know, someone else wrote little on you wrote in generally you're like, Yeah, I mean, it's just how it goes. Yeah.

James Bennett 6:57
And, and yeah, like I said, Python kind of fit my brain like PHP. I give a lot of credit to PHP for making web programming so accessible to so many people. Like at that point in history, because up to then, it was basically you had to learn CGI, which is kind of a complex and tricky programming model, and probably had to do Perl, which has its own quirks. And it's kind of complex to learn at first. And PHP made that so much easier. Because it was just write this and you know, you can you can intersperse a little logic with some HTML and just upload it and it works.

Carlton Gibson 7:41
I mean, that does that, quote, bad mate solve the web problem quickly. That was it's kind of gone. Yeah. And I still hold that, in my mind, you know, has this, you know, whenever I'm thinking about Django, and what's good about Django, and what the strong points, it can try and hold that, you know, Python still hasn't got the deployment story of just stick it up there. And it'll work. But yeah, that solve the web problem quickly. I, you know, I kind of think that that's something that Django has going forward as well,

James Bennett 8:09
we never had the kind of like mod PHP of just upload some files in a directory and your web server will run them for you.

Carlton Gibson 8:17
No, we didn't. But the general goal, and still, I still hold it. And you know, when you say you give credit to PHP is exactly right. It's like, you know, how did I get in? I picked up the PHP and MySQL programming book,

James Bennett 8:31
and PHP had not made it that easy. I don't know if I'd be here.

Will Vincent 8:35
Yeah. Thanks. One of the things I've always been impressed by James, that you've stayed so involved in Django itself, both on the technical side, and also the community side. I mean, this is true. I mean, when I joined the software, the Django Software Foundation. You were on there, you were also actively involved with the technical things. And you had do you actually drove the development? I believe that the the technical board in part because, you know, you were I think the person, you were involved, you had your hands and everything.

James Bennett 9:05
So the technical board was with Jacob and Adrian. And I want to pause and give them a ton of credit. Because they set a really great example. And they did some great things for Django. I mean, from the very beginning with opening up to other people being given commit access to then stepping back. Like one of the biggest milestones and potential problems for a project or community like Django is whether it can survive the loss or the moving on of its founders. And they set it up to succeed at that. And then they stepped back and they said, We don't need to run this for the rest of our lives. And then we got the technical board. You know, we still had at that point, the tech pickle board and the committers the core team as the decision makers, but they deserve a lot of credit for that, because they set Django up to succeed and be hopefully sustainable in the long term. Like there are other projects that never really get over like the, the their founder or their kind of like old guard team and just kind of cling to that for as long as they can.

Carlton Gibson 10:27
Part of that is being I guess, being open to the yes. I mean, I remember when they stepped back and it was, you know, BD FL But BD FL till we stepped down and then out what's going to happen now, but the Django has was had quite a big contributor base and this was historically open to new contributors. And is that cultural, or is that?

James Bennett 10:51
I think they I think they did a lot to encourage that. They were very open to feedback. I mean, even before Django was publicly released, they were kind of showing it around to people that asked me opinions. You can hear stories of like Ian picking being asked about the thing that became Django and offering his opinions on it and kind of the the RM used to be a code generator, and there was feedback to you maybe don't do that, like, Yeah, I think they really set the tone for that by by being open to feedback to other people jumping in and helping out and being willing to not be gatekeepers of Django forever, but say, Oh, well, this person is doing good work. Let's give them a commitment.

Carlton Gibson 11:37
Yeah. And one, one thing I've always liked, is the the approach for consensus looking for consensus in that, you know, it's like, well, you know, actually, there's, there's not an a consensus for agreement. So we'll just hold off here, or we'll, we'll carry on the discussion to until say, we can find that. You know, it's a real strength. And it's not just one person going there. I think

James Bennett 12:01
people get frustrated, because it seems like it can take forever to get something done in Django. But I do feel like Django has kind of slow and steady approach to, we want that, but we'd rather have the right version of it than have a version of it right now.

Carlton Gibson 12:18
Yeah, no, I mean, it's the other day, I was commenting on the channels repo about, you know, the development slow, and it's been slow last couple of years, but it's inexorable, you know, year after year, it slowly moves forward. And yeah, you know, one way to speed that up is, you know, I say one way to speed that up is to join in. But, you know, the reality is that Django is a slow moving beast, you know?

James Bennett 12:43
Yeah. And I think it's also been a benefit in a way because Django has maintained a lot of integrity of what Django feels like, despite all the changes that have happened. When I did my RM tutorials at Django con, I mentioned this, I would take like the, the actual blog model that's used on the Django project weblog and go through different stages in its history and be like, doesn't this look awfully familiar? Every single time? Yeah. Okay. Nice. And I think that's contributed a lot, the kind of pace and the kind of will let's do it, right. Even if it takes a little bit longer, has helped Django maintain that integrity over time of this feels like Django, even as new features get added, even as things get rewritten.

Will Vincent 13:35
Well, that's even I was thinking about about that today, because black, the Python format, or just got out of beta, and DEP eight has been around and approved so that, you know, once that milestone was reached, so you could say, well, another framework could have thrown black in earlier but you know, there was a process there, all these extra steps, people committed to that process, and it will be in there. And when it's done, it's done the right way people can see the discussion. You know, so I think as you said, taking a little bit longer having a process wins out in the end even and people can always just use it themselves to I mean, that's the thing with the ecosystem and third party packages. Channels. Yeah, there's there's like an off ramp for I really want to do this. And resolution has an avenue. Yeah.

James Bennett 14:21
Dragon was was kind of encouraged. Doing things third party to begin with and building consensus in the community around yeah, this is a good implementation. This is a good way to do it. And then bring it into Django. So that happened with migrations that happened with channels. Yes, key stuff. Yeah.

Will Vincent 14:42
Yeah. I mean, even though you Well, I want to hear you talk about the technical part. I was gonna say even just the community part that the DSF you know, that we had Anna on recently, last week, who's the current president and she's been on The board for five years. And I've been on now three years, and there's a natural cycling of people on the board. But there is the sort of passion and knowledge hopefully gets passed along. I mean, your Secretary James, it's, you can't assume that someone is going to volunteer for 10 years on the board or as a core committer, though, you've, you've managed to do it a long time, James. So there's a healthiness in terms of having that model and, you know, do what you can when you have to step away you can, and that keeps the goodwill in the community. Right? I mean, I know for you, right, you had a whole spike of work stuff. On top of all the Django things you were doing. Yeah, a couple years back, which made you need to step away. But you're still here, you aren't right? You haven't. Rage Quit, hopefully. So well,

James Bennett 15:43
I've reduced mark my involvement a lot. I used to be on the DSF board, I served some terms on the technical board, I used to be a lot more active on the developers list. These days, the only thing I really do in the Django project is I'm still on the security team. And not super active there. But every once in a while I'll jump in time to review something

Carlton Gibson 16:11
timely, important, call it.

James Bennett 16:15
I hope to be I think, again, that's kind of the project and the community are healthy enough at the moment. And I think, again, that goes back to like Jacob and Adrian setting things up that way. But they're healthy enough at the moment that people can step back. And other people are stepping up. To do that.

Carlton Gibson 16:39
I mean, we got to hope that you can step back because, you know, I mean, open source and burnout go hand in hand like, you know, yeah, coffee, I

James Bennett 16:48
wasn't intending to have like the mic drop of the new governance. And then all right, I'm out. But

Carlton Gibson 16:57
you mentioned the governance. So that that was the abolition of the old Django core, and then moving the the man that sort of the governance of the framework to the DSF. Membership. And yeah, but the, the rebranding of roles, so there's mergers and committees emerges and releases and rolls like this, and then the technical board taking that role that was DEP DEP 10. Right? Yeah. Well, one thing that I was worried about, and, you know, I've got you here was the kind of knowledge base, these are the old knowledge, the old, you know, the established knowledge to sort of just disappearing, as you know, you know, I looked at, I looked through the old list of the core committers. And they're all like all the people that built all the features, and if they're not there anymore. I was just worried that we'd lose that that kind of tribal knowledge sightly thing.

James Bennett 17:54
I feel like I feel like people are still willing to like answer questions. I joked with wrestle Keith McGee a couple times that my role in Django now is to be a grumpy old man who remembers what happened.

Carlton Gibson 18:08
Yeah, why is he that way?

James Bennett 18:13
And every once in a while, just jump in. And but at the same time, there are plenty of other people filling that role, like I saw. You know, Tim, just recently in Tim Graham, yeah, in a thread about email configuration, jumped in with Well, here's this old ticket, and it never really got anywhere and here, here's some thoughts from when that happened. See you there there other people stepping up and Lake Carlton, you've been around long enough that you are you have a lot of that context. Now. You've seen

Carlton Gibson 18:50
the last few years doing the fellow roll like so basically live in track. That's that's where I've you know, deepened my knowledge massively so okay, I was working on rest framework and then but to come in and have to go through tracking when an issue report comes in and have to find the history and exactly why it wasn't. Yeah. You know, you do that for a while. It's okay. Yeah, I can I can not I used to have the issues is

James Bennett 19:17
just impossible now, but I used to like 1010 years ago or more, I used to every once in a while, just go through every open ticket in in Django is track and read all of them, see if any of them could be closed, see if any of them needed to be bumped? Like, is there anything like any easy like documentation, tickets or things that can be promoted as Let's get this one done for the next release? Yeah. We can't really do that anymore. But you still you develop that feel for what's out there. What's up? It's like, oh, yeah, I remember there was a ticket about that.

Carlton Gibson 19:51
Yeah. And you try and find it and that that works. And then you know, and but just the other day, Claude, there was a discussion on about what was it? I can't remember the exact details. But closer. Are you talking about this ticket? And this? You know, 10 year old ticket? I like? Yes. Cool. Thank you. That was the exact ticket. I was I need to find. So yeah, I mean, I guess the history is still there. And what's, you know what's interesting, you talk about Jacob and atria and you see a 10 year old discussion, or 12 year old discussion or 15 year old discussion where, you know, handling it in a very gracious and open way and is exactly right. Super.

Will Vincent 20:31
James, another thing I want to ask you about is you have given a lot of conference talks over the years that I mean, that's how I first knew about you as seeing these talks. And I wonder if I could ask you about so this was from pi con 2014. Django the good parts? Okay. I don't know if you recall your thoughts there. But I thought that was a really I probably still interesting ones. Yeah. But that that idea. I mean, there was, you know, Java, I guess that was when, what's his name? There was JavaScript, the good parts, right. Yeah. That was the thing and but it is one of my favorite talks is Jacobs from I think pi con 2017, which is a three hour build your own web framework, where he basically goes through these the decisions you make and you know, do you write your own templating language? Do you use something else? And what do you use for the web server? And it sort of distills a top architect level view of of these things? And anyways, if you recall that you're the good parts talk I, I watched that a couple years ago, and it might be interesting to see if it still holds up. Eight years later. So let's see, I have will put the slides in the notes if they're sure they're up somewhere. Yeah, they're

James Bennett 21:38
somewhere. I'm sure they're online. So let's see, what did I suggest HGTV abstractions, the request response cycle, the slow and steady approach to features and apps as the good parts of Django. I'm sure there are more good parts, those are just kind of the ones that I that I focused on. I think that still holds up. Like I think Django goes, you know, request response cycle and HTTP abstractions are still quite good especially. And this was in comparison to doing like your own role whiskey type programming. And for people who've never done that, like whiskey is kind of CGI adapted to be a Python thing. Like it is literally the CGI programming model is kind of lately adapted for Python. So there's all this like, the way for people who've never done CGI, the way that it worked was you would have your script. And the server would put information about the incoming request into environment variables, and the body of the request into the standard input stream, because it was a Unix programming model, and then start your script. And then you would do your processing and send your response headers and response body out on the standard output stream. And so you had to do all of that processing in the script of knowing you know, which magic environment variables have which things and how am I supposed to parse them? And how am I supposed to handle them. And whiskey is similar in that it passes you a dictionary of the environment. And the keys, in fact, in that dictionary, match up to the traditional CGI variable names. And then you return. And whiskey is a little more composable, that every single step, like if you have, you know, one whiskey app wrapping and other both of them have to parse that environment dictionary. Like the the response API is kind of complicated, because you have like this thing that you call to start the response, and then you return the response. And so it's, I really do think that Django those abstractions are, are pretty good.

Carlton Gibson 24:11
I think there's evidence for that with the move to ASCII as well, because it was Andrew did an amazing job. And like, he was just able to not just do it, I don't know just about he was able to bring in an ASCII request that maps kind of parallel to the whiskey request. And inside of that, beyond that request object, kind of the insides of Django were like, Yeah, I don't even notice. It's yeah, so we're able to put in a totally different request handling, sort of application layer, and Django is on touched virtually.

Will Vincent 24:47
Yeah, well, we had Karl Mayer on from Instagram, on the podcast, and I think he said, pretty much the only part that hasn't been rewritten by meta Facebook is is that very Part of Jango. And he thought they are they thought they would never probably swap that out cuz they didn't need to, whereas they changed the ORM. And you know everything else. But that bit was pretty rock solid.

James Bennett 25:10
I mean, there definitely are other like libraries and frameworks that provide the request response abstraction as objects in a similar way. I just think that Django that's one of the things that Django got, right. And I'm sure there are other good implementations that I think Django is is really good, too. We talked about like the the slow approach to features. So I think that still holds up apps. Absolutely. I've been, I've been a fan of Django apps, like I gave a talk at the very first Django con, which is 2008 and hosted at Google, about like designing what I thought were good Django apps. And I've talked about that a lot before. And sense that the app abstraction of you can build sort of a self contained unit of functionality, and then compose and reuse. So things like, you can build a contact form, you can build a blog, you can build like all of these different types of features and functionality, and compose them together to build a Django site. And I think that's really, really crucial, because just providing that abstraction at the level of not like a database model, or a view, but at the level of a whole interconnected unit of functionality for us for a website, has been really, really crucial to Jango success, because it gives you that level to think about, and it gives you the ability to package those things up and distribute them. Or even if their internal, you know, reuse them across different projects, and saves you a lot of time, makes it a lot easier to reason about these things. And so I've always felt like apps were kind of like the secret weapon that made Django so good. I

Will Vincent 27:16
should mention you have a Django Contact Form app among several others that focus Yes,

James Bennett 27:22
I need to, I need to do the Django 4.0 updates. And I got a I think it was Marius pinged me to point out that the new form rendering is actually going to require me to do some work with the contact form. Because the contact form already had a method that uses the same name as what was added for the new form rendering

Will Vincent 27:47
cards. And I know you had a question based one to go and code. Well, I just wanted to say something, which is that apps, when I see people who are new to Django, so especially people coming from another framework apps is actually something that trips them up. Are they fair little that angry about but they kind of like, this is stupid, why did why does Django have apps? I want it to be a certain way. And I see this various discussions, it's like, well, you can, the whole point is you can do it however you want. You can have one app for your entire site, or you can rely on abstraction. And then you can also rely on these third parties. But that concept, maybe it's coming from different frameworks. But that's something that someone coming from another web framework I find trips them up initially. Yeah. Because there's confusion over what it means. Yeah,

James Bennett 28:33
it is a thing that I've had to like, I tried to teach and I had to explain like it a few different companies with people coming from other stacks. And their assumption is, oh, the app is the thing you deploy. And it projects versus explaining like the project is the minimum deployable unit of Django. But, you know, the app is kind of the atomic unit of functionality.

Will Vincent 28:57
The question is, well, where do you draw the line? It's like, well, well, there's guidelines. But that's, it's I think, that's, you know, that's the piece that is unsettling to, to those folks. It's like, okay, but but how? And,

James Bennett 29:12
and it is, it can be tricky, and like, I'm not gonna say that I always do it, right. It's not something that there is a single rule you can follow that always gives you the right answer.

Will Vincent 29:24
Right. Well, that's kind of what I tell these people say, Well, yeah, maybe it's an extra step or thing to think about, but Django. On that balance of customizable, Django is actually quite customizable considering it has guardrails. And that comes at the cost of the apps and some other configs where it could be rails, it could just go boom, one way, but it makes it easier to be malleable with your construct with

James Bennett 29:47
you. It lets you turn things on and off. It lets you have you know, different configurations of features that you can kind of toggle. I think it also helps that Django the Django itself has that approach. So like the apps in Django contrib? Yeah, it was like the admin and sessions that you can see that you are composing these things together. Right? Just one more, right? Yeah.

Carlton Gibson 30:14
Carlton, what are you gonna say, fall off that just one more comment is that people get to kind of addicted. And what I've seen as a working Django programmer for many years is you could go to a company and they're stuck on the old LTS, and it's just about to go end of life. And they, they're struggling to update because they've got, you know, 33rd party apps and 29 of them aren't really aren't really maintained properly, then they're in a kind of bind. And so, over the years, I kind of developed a kind of very conservative approach to taking on a new app, you've got to be you must be cautious here. You mustn't miss check. It's properly maintained. You must. Yes, the counter. That's the counterpoint I guess is that you can

Will Vincent 30:58
third party app you mean Carl?

Carlton Gibson 30:59
Yeah, but yeah, the third party app if you're going to take on a dependency like that, and then you find yourself kind of stuck. So I, I tend not to use the LTS myself, but I asked on Twitter recently what you know, if you use the LTS why, why'd you use it? And one of the biggest responses was, well, you know, by the time our third party apps are updated to be compatible, you know, we go LTS to LTS, and that can serve us better than, you know, trying to

James Bennett 31:28
I think trying to fly like the the API compatibility promises that we have now. Make it a little more make it a little nicer for a lot of places to go LTS LTS, because, you know, Django itself kind of makes the promise that if you're running on this LTS, and you have no deprecation warnings, you can safely upgrade to the next LTS. Yeah, yeah, without having to change your code. Now, you would want to test any third party stuff you're using. But that gives a very nice upgrade path. And I've dealt with setting up dependency management workflows at several companies, and how to how to keep things up to date. And that is a perennial issue.

Carlton Gibson 32:14
Yeah, and I recently updated a project on 111. And it was remarkably smooth to get it to 2.2. And then 3.2. And it was just like, you know, and I didn't bother with the intermediate ones, because, you know, ROM had warnings. Those up, and it was, it was, that was lovely, to be honest, much better than the audience.

James Bennett 32:34
But it does, it does get complex when you've got I mean, even if you're not using that many like Django apps, you're probably using some number of third party Python libraries and things off, you know, pi pi, and you need to keep those up to date. Even if you're not upgrading Django. Yeah. Yeah. So that's, that's a fun thing to do.

Will Vincent 32:54
Well, so I wanted to ask you, you, you wrote a post on how I'm testing now from 2020, which is related to this that I thought was pretty interesting. And testing is something we'd love to ask practitioners about, since there's quite a variety of ways it's done in the wild. Okay, we'll link to that article. But I wondered, just, again, you've you've worked at a number of companies using Django with how do you think about, you know, practically speaking, proper testing, you know, what are the tools you like to use in terms of the hierarchy of priorities that you'd like to see on in a code base,

James Bennett 33:31
I like to see test, like, any tests are better than no test. I'm not particularly like a test driven development person. I'm kind of I'm skeptical on most, like capital letter methodologies for building and managing software projects,

Will Vincent 33:51
like full stack developer.

James Bennett 33:55
So I may write something about this in the future, like, you know, I understand that a lot of these methodologies there, there's some essential insight that somebody caught once and then tried to propagate that but it's the everything else that grows up around it and kind of all the rituals and practices that because because so often, like the the things that make a project successful or not, are not really, you can't replicate them to the next team, the next project, the next thing like it's, nobody's figured out how to do that yet. And software. So the I do like tests, I, for my own personal stuff, I write tests. I use talks as my test runner, because typically I'm like I'm testing against a bunch of versions of Python and Django for like Django apps. And I was like Carlson talks makes it very easy to manage that matrix of things. At keep them running. I use I prefer the Python standard libraries unit test module over pi test. Left places. That's interesting. Yeah, been pi test shops. But I, I prefer unit test module

Carlton Gibson 35:22
is what is because pi test is very popular now. And you know, we still use unit tests for Django on test suite. But what are your own reasons for favoring it?

James Bennett 35:38
So I mentioned this a little bit in the blog post that I understand, or at least I think I understand what pi test is trying to do with separation of concerns in testing. And how it wants that. I'm not the biggest fan of dependency injection in Python. And the particular way pi test does it. I just feel like that at least I kind of struggle with it. Because I feel like fixtures can be getting injected and found and looted from so many different places, that it's hard for me to know what's available. Wait, where did that one come from? What does that one do? It just I have a harder time reasoning about everything that's going on. Versus like a unit test style. Where everything is right there on that class, and I can see all the things into doing or if it's from a parent class, I couldn't see what it inherited from and I couldn't follow the important thing.

Will Vincent 36:40
It's a bit like function based views versus class based views like Carlton I saw there's, you know, you were waiting to Twitter someone

Carlton Gibson 36:47
like foolish, foolish she got.

Will Vincent 36:51
I saw a glance from a distance and said braver than I am.

Carlton Gibson 36:57
Yeah, I

James Bennett 36:58
think I think Django is built in ones could have been done differently. But I understand why they were done the way they were. But in general, I'm a fan.

Carlton Gibson 37:10
Yeah, I mean, my, the claim I made was that they give you a namespace to break your, your logic up in. And I think the issue is that we don't teach, we teach, here's one line, and you've got a list view. And that's kind of deeply mysterious. Whereas if we taught, you know, a class with a get handler, and then you declare your view, then it's just, it's exactly the same as a function based view at that point. But it's just got a bit more structure. If you need to break your your, you need to break it up. And I think, well, yeah, that was my point. Is that Hang on? What are we what are we arguing about here? are we comparing function based views to changose? generic class based views? Or are we comparing?

James Bennett 37:53
And I also, I mean, I feel like I lived through the entire era of generic function based views. And of that being function based views being the way you did things in Django. And I remember how much more difficult it was to like, add functionality as like, okay, now I need another keyword argument. And I need another conditional in the body of the function to handle that keyword argument. And I need to account for it everywhere. And if you if you ever go back and look like maybe you'll link one of the old Django documentation, versions with, like the argument signatures of the old generic views back when they were functions, like it's two gigantic list of stuff.

Will Vincent 38:36
See, this is that grumpy old man wisdom that we need on the young folks, Carlton, right.

James Bennett 38:41
Exactly. Yeah, like, the class base is like the generic views in Django right now that are class based, are the way they are because they tried to replicate exactly what the old function based views could do. Like we we wanted the functionality before and after to be the same. And so that's why they were written the way they were. That's why, you know, if you wonder about late choices that seem weird in terms of what's broken out into a mixin. And what's inherited into the, it's because there was a deliberate attempt to preserve exactly the set of options you had with the old ones, so that you could just go straight from one to the other.

Will Vincent 39:20
Well, it's Carlton, you've mentioned many times. I mean, Tom Christie has Django vanilla views, which is perhaps a clean approach at doing it without trying to mimic the old function function baseless.

Carlton Gibson 39:32
Yeah, I mean, vanilla views are sort of, they don't handle all the, they do let the basic create views and, you know, the form handling views, and then list in detail. And for those, they've kind of, you know, 1.8 times they were sort of feature equivalent, but they're just a more direct style without make sense. And so, I always recommend Pete because there's only like four files in that package. I always recommend people to go and read the source code. have genuine interviews because it kind of it. It's really eye opening. So Oh, yeah, actually, what's going on here is just turning requests into responses. And you know, there's not too much to it. And then you go back to classic class based views and the Django ones. I see the same things happening. And that's a nice learning any point.

James Bennett 40:22
Could Django simplify? The ones we have? Or I don't

Carlton Gibson 40:27
know, of a

James Bennett 40:29
compatibility issue?

Carlton Gibson 40:30
Yeah, no, not now. No. I mean, our USP is we don't break stuff, right? Yeah. Like, and we can't. We can't change the generic class based views that we ship. I'd wait. You know, maybe, but no, if you are

James Bennett 40:46
in error, I remember when, when the old forum system or the manipulator system as it used to be called. And then there was Django dot new forms, which became Django dot forms. years later. So yeah, Django dot new generic. Yeah. Oh.

Carlton Gibson 41:08
There we go, Carlton. Okay. If you write the dare poll plus one it has that.

James Bennett 41:19
I think you're right. There's just too much backwards compatibility. And it's too important to feature to rip out and replace like that.

Carlton Gibson 41:27
And it's not, it's not that it's bad code. It's great code. It's great code. It's well documented. It's well tested, it's got everything going about it. It's just, there's a learning curve. And it's not perhaps as clear as we'd lay out if we started fresh. But

James Bennett 41:41
and at this point, it's not clear to people why that learning curve exists, because that complexity is entirely you mentioned, due to the desire to maintain exact compatibility with what the old function based views did.

Carlton Gibson 41:57
Yeah, yeah. I think yeah, I mean, I think you mentioned that really, if you missed that, that's

James Bennett 42:03
that you mentioned, you know, we don't we don't break compatibility. Yeah. As a policy that, you know, when the class base generic views were introduced, they had to be exactly equivalent features that,

Carlton Gibson 42:16
yeah, okay, interesting. So, gone. Well, did you wanna?

Will Vincent 42:22
Yeah, I just gonna ask about service layers. Smoke, okay,

Carlton Gibson 42:25
because there's a big elephant in the room, which is the ORM. Right. So,

James Bennett 42:29
yeah. The original question about testing, like, it's not that it's not, but I think pi test is bad. Like, it's, it's really good. It's really well written. And I do appreciate what it tries to do with separation of concerns. It's just, for me, personally, it doesn't quite fit my brain and I find it a little harder to reason about, like, that's why I prefer the unit test styles.

Will Vincent 42:51
Service layers ORM, pick one.

Carlton Gibson 42:56
Well, let's talk about your you've taught the ORM you've, you've contributed to the ORM. How, here's a question I like to ask our contributors, how do we make how if you're, if you've got a young contributor wants to come along, and they want to get into contributing to the ORM? How do they approach that? How, what's the route in to grokking? The ORM? Because it's, it's big and scary and multifaceted.

Will Vincent 43:20
Um, even Tim said, so yeah. Yeah, he's that was the one area I was like, Where are you not rock solid? Well, Laura

James Bennett 43:32
Lee, we mostly relied on like, everyone once in a while, so like, I'm sure you've heard Russell tell the story of listened aapko when she first started contributing, and picked this really deep like, gnarly, ORM ticket to do that, like when she submitted the patch, it took Russell and, and someone else, like, a couple hours with a whiteboard, figuring out what was going on. And that yeah, this is the right solution. And she just kind of like, tossed that off in the course of a sprint. And we've always kind of relied on the kind of genius level I don't I don't know how she understands the ORM that well,

Will Vincent 44:21
like walking in late to class and you know, solving the proof that's never been solved yet to MIT. Yes. So

James Bennett 44:27
Django has been very lucky to have people like Ola who just show up every once in a while and can do that. We, we need to do better with that like the ORM I would say, first try to understand the different abstractions like like start with, you know, models and managers and query sets and then you know, maybe look a little bit at query, look at database back end and look at the like the query object. Look at the sequel compiler, like learn to think of it Yo query, I actually think a good analogy is to learn how the template system works. And learn how the template system like parses into a tree of nodes, and then walk through rendering all of them. Because what the ORM does effectively is build a tree of expressions and walk through with a SQL compiler, turning them into SQL, and kind of understanding that pattern and what the major abstractions are. And then you can start reading, like some of the scary source code in, you know, query logic. And I haven't looked at that in a while, that it all

Will Vincent 45:41
comes back to compilers. Right? That reminds me, we had Carson Gross who, who wrote htm X. And he's a big fan of writing programming language from scratch and teaches them now and he was, uh, he had some line, he's like, oh, yeah, you know, I just read a programming language for this problem. It's easier than you think. I was like, for you.

James Bennett 45:59
Actually, I've been thinking about maybe doing a series of blog posts on like, Let's build the Django template language. Okay, just go through like, Okay, here's what we're going to parse it it because the Django template language is incredibly simple. And the implementation is not that hard. Like, if you have, if you're, if you're really motivated, you can probably read through it and work it out yourself. And if not, like, a little bit of guidance, I think we'll get you there. Like, just introducing the concept and what's going on. And then when it all kind of fits together in your head, and you understand, that's how it does that. And now you're ready to learn how

Will Vincent 46:43
to reading to reading that. You know,

Carlton Gibson 46:46
I'd read that right.

James Bennett 46:48
Yeah, I've got I got some things I want to write I need to decide. I thought about turning that Orem tutorial into a book, but I don't know if I'm ever gonna get around to it. Oh, Carlton

Will Vincent 46:57
loves when we talk about when I talk about books with potential guests. When you read a book you wrote a I have your you wrote, yeah, I have that. I was you built a blog in it, I believe, right. Yeah, it was a

James Bennett 47:08
blog. And I think something else that was built in that one. Yeah, that was I got a copy of it somewhere.

Will Vincent 47:15
Oh, gee, Carlton, as they'd say,

Carlton Gibson 47:17
yeah. Oh, JC don't told me and taught me. Well, there's this Twitter thread, you know, just my children are like, Dad, you have to play more fortnight because I didn't know any slang or any of these street abbreviations.

James Bennett 47:30
And I missing out on playing on Twitter, or am I missing out by?

Carlton Gibson 47:36
You know, you're not missing out? It's Will's just teasing me.

So following Okay, so learn the abstractions to get into the ORM. And then recently, there was a gone it was recently right, there was a few articles on using Django, as are the ORM versus service layers. And I think that's really interesting. Because, like, why Django? Why do RM like versus other approaches? That's I think that's a massively interesting topic. We can link to those blog posts. But be nice to we talked

Will Vincent 48:09
about with some guests back when you wrote it, James, actually the Okay. looked at those. So here's an expert. Here's an OG expert out in the wilderness saying giving an opinion on Django that

James Bennett 48:23
the ORM more than anything is kind of the scenic one on Django at this point, it's the thing that if you're not using it, why are you using Django at all? Like, the, the request response abstractions are nice, but there are other libraries that will give you request response abstractions in Python. So basically, it's if you're not using the ORM, why Django at all, is kind of the question. And I'm not sure the answer at that point is to use Django. Like maybe you want some of the abstractions you want, like the concept of apps, but you want to use another ORM with it, or you're not using a database at all, you know, that can make sense. And you can do the kind of minimal Django like I think some people even put together examples of how to do a very minimal Django

Will Vincent 49:15
setting might be a talk on it.

James Bennett 49:21
But as far as the ORM itself, like, like putting service layers in front of the ORM, like, the reasons people give for wanting to do this are always you're going to end up reinventing the ORM. Or you're going to end up introducing a lot of complexity to make something like sometimes people do it for testability so they can swap out a fake database or rent that during test runs. Some people want to like hide the data access logic, and you know, have separate representations of like business objects and business logic and their design patterns. that, like I mentioned in the blog post several times, like if you really want that you really believe you want, you know, data objects and business objects and explicit logic mapping between them, you want the data mapper pattern, and you want to use sequel alchemy. And you want to use a Data Mapper, or, but Django is not a Data Mapper ORM, it's an active record or M. And you're trying to take this design pattern that works fundamentally very differently from how Django is or M works and push it on to Django. And that's not going to go well. And you're going to end up having to rewrite large chunks of the ORM to simulate or M functionality and your service layer. And introduce a whole bunch of complexity. Like I think, in a lot of cases, the problem is, and I touched on this, I think in the first blog post on that is people trying to untangle interdependent code, like these really complex code bases, where it's like, everything does everything I have worked on code bases, where like, there were some models that had a policy, that you always had to do save with explicit Field list, because you didn't know what else might be modifying that model at the same time. And so you'll make sure to only actually save the fields, you're changing to the database. Like, and I tried to give what I think are some good guidelines for how to have models as the API of your app, and what kind of access from other apps and other code into a set of models to allow. And basically like, things like you shouldn't ever reach into another apps model and start tweaking its fields directly and saving late like don't do that. Instead, you expose logical methods, like the the joke that I've used a few times that I've always heard is, you know, if you want to walk the dog, you don't reach down and pick up its leg and put it down and pick up the next leg and put it down, you ask the dog to walk, because the dog knows how to walk. And building models that know how to do things, rather than having to reach in and grab this field and set it to this and grab this field and set it to this. minimizing the amount of internal structural knowledge you need about those models, because they're public API, their list of methods that they expose, gives you the operations you need.

Carlton Gibson 52:41
And then the table level, you might do put that on a manager rather than Yeah, myself sort of thing.

James Bennett 52:48
Yeah, like like row level operations on the model table level operations on the manager class, alternate constructors on the manager class. The I think that it's hard to do. I, I've advocated for it. I've never seen it completely pulled off successfully. I don't know that I've ever personally managed to completely build it up successfully. But at least putting in the effort and trying to do it gets you a little better results. And then the rest of it was kind of like, well, what do I do with these really complex things like, you know, somebody is canceling their subscription. And there's like six different models that need to be updated when they cancel their subscription. And it's like, well, if you put that in a service layer, like saying, well, it doesn't make sense for this thing to be on one model. Well, it also doesn't make sense for it to be in one service method, because it's doing all these different things like that, that's moving it around, while keeping it that complex doesn't actually help. So that's the other kind of issue there. And there are patterns for that, that that's just a matter of like familiarity and experience. And sometimes there's going and looking things up and being like how do people do this? There? There are I think Brandon Rhodes has been trying to do like design patterns for Python, these Python patterns repository. I don't know if he covers like anything other than like the the original design patterns book. But there's a lot of stuff out there on how to like, how to handle these kinds of like complex cross cutting concerns in code and how to break it down so that you don't end up with like the one method that does everything and touches everything.

Will Vincent 54:34
I had one sort of larger question. Is there any more specific ones? You had Carlton? James?

Carlton Gibson 54:41
Yeah, I mean, just on that, I think, you know, that the whole point you we made right at the beginning about, you know, doing the web problem quickly, like the ORM fits that. For me, the ORM fits that niche really, really well. And most times if you're trying to do the web problem quick But you don't need these extra complex constructions around it. You just need to make sure that as you grow, you maintain hygiene. Because yeah, it will get gnarly, it will get intertwined, it will get difficult. But that happens to every project no matter what architects use.

Will Vincent 55:16
So my concluding question is open ended, which is so as we as we record your, your you, you're not currently working for a company. But you've been

James Bennett 55:28
unemployed for just about a week and a half at this point.

Carlton Gibson 55:33
Okay, is that home baked bread behind you? I see. Yes. Yeah, I didn't write. Okay.

James Bennett 55:41
That was that was homemade. But I will have made it but I have been enjoying. Yeah.

Carlton Gibson 55:47
Nice.

Will Vincent 55:49
So my question to you is, what kind of opportunity given your experience is interesting, like you've worked at small companies, large companies, you've tackled all sorts of web Django problems, what you know where you're at now, what kind of things would be interesting? I don't, I don't know. Have you managed teams? I feel like you've been more on the code side. But I don't know what so anyways, what what are you looking for? What's interesting now to you,

James Bennett 56:14
I've never been a manager, I don't really have interest in being a manager. I've been like sort of climbing the individual contributor ladder. My last job I was, my official job title was staff software engineer. Like I put up a blog post about it, where I said that I like working someplace where I can use my Django experience and be a resource to a team that perhaps is using Django and Python, but not being defined by it. Being able to do more than just be the Django guy at a particular company. And it's like, it doesn't have to be any single particular thing. But just getting to branch out getting to learn stuff. Like I spent the last year, I didn't set out saying, I really want to get good at Docker. And I'm not really good at Docker. But I ended up doing a project that involves learning quite a bit about Docker, how to do Docker files, Docker, compose, orchestrate, you know, Docker based projects. And that was really interesting. And because they were Jango services that were being Dockerized, like, there was opportunity to use the Django specific knowledge. But it wasn't just oh, we've got a Django person, let's have him go do Django things.

Will Vincent 57:36
I would love to see a blog post on that, by the way, because that's a perennial issue is, well, I don't know that Docker approach for Django, I know that it isn't, it's

James Bennett 57:46
like I did. I did not much out there was okay at the time, and other people are gonna pick up and iterate on now that I'm gone. Yeah, it's that that's the kind of thing that I look for is, I don't necessarily know what's going to be interesting to learn, but having the opportunity to branch out and learn other things and do other things that aren't just being defined by Django. Because it is important to me that, like Jango is important to me. And the things I've done with Django are important to me, but it's also important that I to me that I'm not one dimensional. That's not the only thing I can do. That's not the only thing I know, it's not the only thing I can learn.

Will Vincent 58:30
And you think that's a icy issue, because the tech industry isn't great around ice individual contributors. There's, there's a sense that trees only grow so high. You know, I mean, other other fields don't have that. But in tech, there is a little bit of that.

James Bennett 58:46
Yeah, like, once, once you specialize in something, it can be hard to be like, people talk about, you know, wanting to like the kind of T shape of like, you know, really deep knowledge in one thing and you know, then kind of okay, knowledge and a bunch of other things. But I don't know how many companies actually succeed at that. And how many teams actually succeed at wanting that, because getting getting to a level of specialization with something you could like it, but that doesn't necessarily mean you want it to be the only thing you do for the rest of your career.

Will Vincent 59:22
So so you're switching to front end JavaScript development only, right? Is that what you're

James Bennett 59:28
what we're hearing your story, actually, when I was back in 2006, I believe I was officially hired to be their JavaScript guy. You could see how well that worked out. Like at the time, I was like, I knew Python, but most of what I did professionally was like a little bit of backend work and then like front end, like HTML, CSS, JavaScript, translating, you know, ideas and designs into actual implementation. You know, 2005 2006 era Friday, and it was a whole different thing. But

Will Vincent 1:00:04
well, like would it be more interesting to be the fifth employee on something attraction where you need to rewrite everything to make it performant, or it'd be more interesting to be the 50th and have to specialize a bit more. I'm sort of curious, you know, where you're at now, which which of those two problems would be more interesting?

James Bennett 1:00:21
I don't know, I actually did talk to a company that was hiring for their fourth person, and first, a dedicated back end person. And that sounded really interesting, like the chance to kind of like start from scratch and have a hand in building everything. We're programmers, we always love the idea of just starting with that clean sheet of paper, and saying, we're gonna do it right this time.

Will Vincent 1:00:51
This time is different. Yeah.

James Bennett 1:00:54
But I've also been talking to places that are that are much larger and are looking for, like someone who can come in and be like, a resource and a mentor on Django stuff, but also do other things. And that that's, that seems like, that seems really good. To me. That seems like where I want to be.

Like, maybe one day I'll do the, you know, first back end person, process and then start everything from scratch, but I don't think it's going to be this time around.

Will Vincent 1:01:26
We can also just consult for equity, you know, with the, the smaller one, right? Because I feel like a lot of it is somebody who doesn't have the wisdom, who might say this is how we're thinking about doing it in a couple hours, you can save them so much time, but you don't have to do it yourself.

James Bennett 1:01:43
I don't know, I've done I've done contracting contracting is expensive. It's expensive to be a contractor in the US at least

Will Vincent 1:01:51
expensive for you or for them.

James Bennett 1:01:55
expensive for the contractor is was my experience of doing it like because there's so much overhead that people don't think about from being full time contracting. Like health care. Yeah, like health care, but on the year of retirement, you pay more taxes. You pay an extra 15% tax for being a contractor. I'm self employed. Yeah. You know this, so it can be Carleton too. Yeah. It can be tricky.

Carlton Gibson 1:02:26
You said what you said one thing. So I'm gonna, you said mentioned mentoring. So I have one more question. I'd like to ask you, and then we'll let you go. But what, what do you think it's something that I'm always thinking about? What's it take to mentor somebody? Well, do you think that the challenge I find is people come they say, Oh, we want to mentor but they don't bring anything to the table? And how do you how do you find that balance?

James Bennett 1:02:49
I don't know that I have a great answer. In my professional career, like working for companies, I've had a little bit of success, getting people from kind of like, post beginner intermediate into like, advanced intermediate to senior, like working with people who already had some basics under their belt and getting them kind of to the next level there. I've had some success with that. I have never felt particularly great about my ability to start someone like from scratch and get them is zero to at least kind of like a reasonable like beginner Junior, you know, first job level of knowledge. So I don't know exactly how to answer that, like the the things that I've been successful with have mostly been, like pointing people at resources that are kind of interesting and kind of showing like, here's a pattern that you might not have run into. But we can do that for this thing. Like not necessarily telling them oh, do it this way, just kind of showing them what options are out there. And just kind of letting them build because I think that is the kind of that's one of those things that as far as technical knowledge as you grow is kind of your mental library of patterns and possibilities and options that you at least know are out there, even if you don't consider all of them for every single thing you're going to do. And so I've had some success with that, but I don't know. I don't know how to replicate that necessarily. And I I don't feel like I've had great success with with people just starting out. Okay. Google, Google Summer of Code. I was probably a mentor and I was very lucky because my assigned student was Yanis I got the easy mode.

Carlton Gibson 1:04:58
Yeah. See? Danis being like Django is second biggest contributor of all times.

James Bennett 1:05:04
Yeah. Yeah. And like so many other things. Yeah. We used to joke that everything you use has been written by him at some point.

Carlton Gibson 1:05:17
This is super. Okay, let's let's call it x, we run up to time, thank you so much for coming on.

James Bennett 1:05:24
Sure, sure.

Carlton Gibson 1:05:24
Thank you for sharing your opinions.

Will Vincent 1:05:26
Thank you. Yeah, so we have links to everything. In the notes, check out James's talks if folks haven't seen them already. And we are at Django Chat, ChatDjango on Twitter, and we'll see everyone next time.

Carlton Gibson 1:05:41
Bye