Podcast audio transcript

DrupalEasy Podcast S16E3 - Andy Giles - GitHub Copilot

Audio transcript

[0:00] Music.

[0:07] Welcome back to the DrupalEasy Podcast. This is season 16 episode number three in today's episode, I'll be talking with Andy Giles about github Copilot, the visual studio code extension and PHP storm plug in that brings A I capabilities to your code editor.
Before we get to the interview. Let me tell you a little bit about DrupalEasy's long form training programs.
First, we have our beginner focus drupal career online that is now in its second decade.
This class meets twice a week for 12 weeks starting on February 12th.
You can learn more at one of our free one hour taste of drupal webinars.
All the details are at DrupalEasy.com/dcO.
Now our second long form drupal training course is called professional module development.
This is 90 hours of instruction over 15 weeks. Also meeting for two half days a week.
We cover topics such as developer tools, dependency, injection, custom plugins, caching and plenty of PHP unit tests.
Class begins January 30th, learn more at our free 30 minute closer.
Look all of the details at DrupalEasy.com/pMD.

[1:19] Andy. Welcome to the DrupalEasy Podcast. How are you today?
I'm doing well, Mike How are you?
Pretty good. So, we've known each other for a couple of years, we'll say at least.
Yeah, you've been in the drupal community for, according to your drupal network profile, 13 years and six months. That's pretty awesome.
Yeah. How many, how many years do you have there?
I think I'm over 16.

[1:42] All right. It's been a, been a minute. You got me beat. But I guess you could say we're both Ogsogs.
Yeah. You are the owner developer hr ITV P.
All of the positions at Blue Oak Interactive. Tell us a little bit about Blue Oak real quick.
So I started Blue Interactive in 2012, I was doing web development for another company and decided I, you know, I should start my own thing and really wanted to focus on drupal uh mainly.
And so that, you know, got me out of my own and um started, you know, going to drupal camps, the regional ones, Atlanta Florida, Asheville, meeting all the wonderful people of the community.
And, you know, just been doing that for quite a while now, we primarily focused originally on drupal commerce uh in drupal seven.
And since then, we've kind of moved just to like general drupal development.
We do a lot of third party integrations with external API S.

[2:43] You know, just anything that's like, uh you know, not able to be done with a module that can just be installed is kind of where I come in and you do a bit of decoupled stuff as well.
We have done recently. We did a drupal next uh next Js front end site, which was, it turned out really nice and was a, a good developer experience, not to say it didn't have its issues, but, you know, so you know some of the, the things that give you headaches in drupal were solved by decoupling.
And then of course, there were new headaches to come along with it all.
Brand new shiny Javascript headaches. Yeah, that's right.

[3:23] So, I'd be remiss if I didn't do at least one A I podcast this season.
So, here we are, we're going to talk about Github Copilot.
So, Andy, and, you know, in as few words, as possible, what is github Copilot?
Yeah, I would say github Copilot is a programmer's friend in your ID E.
It just reduces the steps between asking large language models questions about your code and getting feedback.
It's right in the ID E, it's continually being improved. You know, when, when it first came out, it was a little rough.
But now, you know, it's direct integration where you can select text in your ID E and ask questions about that particular piece of code or there's a, there's now a chat feature so you can ask just general questions within the ID E.
So you don't have to open up a separate browser window, go chat GP T or whatever.
LLM you're using. It's, it's directly embedded.
Yeah, it kind of saves you that step of every time you, you wanna, you wanna use A I from opening up cloud or cha G BT or Bard or whatever and giving context.
And yeah, so I think, you know, the biggest part of it is the context with the integration with Copilot, you know, before, if you before, which was like, you know.

[4:41] Two months ago, uh you'd have to like copy and paste code back and forth into your browser, you know, to interact with an LLM, to give it the context, it needs to answer your questions.
Whereas now copilots directly integrated, you can, you know the, the tabs that you have open are automatically as context that you can select, you know, a block of text.
If you have a particular question about that or there's actually I, I just read this week they rolled out workspace context which will actually attempt to like create embeddings from your uh entire project, and then do and we can get into how all this works.
But like it does a search and then submits the search results to copilot to provide that context of like the larger project as a whole um to answer your questions. So pretty crazy.
Yeah. Before, before I first started using it day to day, I just kind of envisioned it as like autocomplete on steroids.
You know, because most I Ds, if, if you have the right extensions or plugins or using PHP storm, which has a lot of the PHP stuff built in.
It's I won't say constantly but almost constantly giving you auto complete suggestions.

[5:52] When you're using github Copilot, it's giving you auto complete suggestions that are just out of this world.
Sometimes fantastic, sometimes a little bit annoying.
But it's really, you know, it, it does that but then as we'll talk about, there's a whole lot more that, that Copilot is, is bringing to the table.
Yeah, it's funny you mentioned the um auto completions in the ID E because that's one of the friction points I've had with integrating Copilot into my workflow is that, you know, when you start typing something, Copilot pops up, the ID E auto completions pop up.
And so sometimes there's a little bit of a conflict there and like the, the biggest problem I have a Copilot right now is that it's pretty like block oriented.
So whatever block you're typing in, that's where it's going to inject whatever it's providing.
So if you have like a use statement, you know, you're, you're embedding an interface or something.

[6:44] It is part of your code, you know, the ID E auto completion will automatically include that interface or that class that you need.
Whereas Copilot doesn't and you know, it just kind of throws in the class and then you have to go back and add the U statement or whatever later on.
So I'm sure that will get better and maybe there's already, you know, some improvements in that.
But yeah, when I first implemented it, that was my biggest headache was trying to fight with the two systems.
So it's, it's, it's not like pair programming where it's you and one other person, right?
It's like, it's like pair, it's like multiple pro programmers, you know, you and then, you know, two angels or devils on your shoulders, you know, constantly fighting for your attention.
A lot of times I would use both, like, I, you know, used to use like a Doc block extension and VS code to like scaffold out the, um, headings of a class or a function or whatever.
And then, uh, and then I'll go back and, you know, erase part of it and have copilot write the rest of it.
So, so have you gotten, so that's interesting because I do in VS code I use, let me see, I have it open right here. I think it's called Doc blocker, right?
I think that's the one I use. So, do you still have that installed?
Or have you like, I do, I mean, sometimes, sometimes that, you know, you learn, you know, this thing quicker for the workflow and so you learn which tool is the most efficient over time.

[8:05] Sometimes it yeah, slows you down. That's interesting.
You mentioned that one because that's kind of one of the the really kind of cool features of Copilot where you can, I don't know if you have to just put your cursor in the function.
I normally just highlight the whole function and then you can right click and navigate your way down to a like it says generate docs, and it will generate a dock block above that function that has a title, a description and then the parameters as well.
OK? I haven't actually used that. Yeah. So it kind of.

[8:37] It does a better job than Doc blocker, the the kind of old school vs code extension, because Doc blocker just kind of gives you the template and says, you know, add your title here, add a description here, but.

[8:49] You know Copilot, it reads your function and it, it writes your title, it writes your description for yourself.
Does it follow like the uh you know, fully name space things for P HPC S and all that?
I believe it does. Yeah. So I just started working on one earlier today.
Let me look real quick. I can probably, yeah, that was one of the other problems I had was just, you know, sometimes either dark blocker or copilot, you know, it spit something out and then P HPC s would fail.
But, oh, I don't have an open, I'm not gonna go looking for it. I think it does.
It, it, it's pretty nice though. I mean, because it's, that's one of the things that A I does really good.
You give it a block of text and tell it to summarize and for sure it can do that. All right. How do you get it?
Like where do you go? What does it cost like if you're using VS code and we'll probably talk about VS code mostly today but it, there is a PHP storing extension as well.
What's the process? Yeah. So I, I only have the experience with VS code.
Uh you know, it, it's installing a plug in just like you would any other VS code extension and then there's a process, I can't remember exactly.
But you generate tokens and get lab or, or github, I'm sorry and authenticate it. Maybe like an o off type thing.
But you authenticate the, the, the extension to your github account and then it's $10 a month or $100 a year. I think it is the current pricing.

[10:13] Yeah, there's a free trial for, I think, 30 day free trial, but that's 10 bucks a month after that, I believe.
Yeah. But then at that point, you know, it's, um, it's pretty much enabled.
I haven't gotten into like, customizing any of the options in the settings.
I'm sure there are some, but I haven't, I know you can exclude certain files from being sent to github for privacy purposes.

[10:34] But yeah, I mean, once you have it enabled, you know, you get a little icon in the bottom right hand corner of your ID E that shows whenever it's processing and it's like, you know, as you're typing, I think once you pause, there's like a brief time out and it'll go, you know, try to make a HTP HTTP request to github to get you some, some magic.
So one thing I noticed is after you install the extension, you actually get two extensions. I'm not sure how that actually works.
I don't know if it's like a drupal module where you download a drupal project, you can get multiple modules.
But when I installed the, the main github Copilot extension, I also got the, what the github copilot chat extension? Oh, ok.
Is that yeah, so when I set it up that has, that wasn't out yet.
But I think, and there might even be another extension just for like github integration that gets installed. I'm not really sure.
But yeah, the github chat has come out recently, semi recently.
And is that one's kind of cool because it basically gives you a little icon and I don't know what that left hand bar vs code is called.
And it literally just opens like a chat GP T window, you know, but again, it's, it's got the context kind of built in.
So you don't have to say I'm a developer writing a phpo, you don't have to write that you just start asking direct questions about the language or your file or your project. So that's, that's kind of neat.
And you can kind of do that. You can kind of have that same type of conversation.

[12:02] In line in your code as well.
And this is one of the features. Uh We're going to start getting to the features of Copilot right now.
But one of the primary kind of interfaces, I guess with it is within code comments.

[12:16] Where you can, if you want to create a new function, you can start writing a code comment that basically says create a function that does blah blah, blah, blah blah, takes these as as arguments and outputs this and has this logic.
But it's something else you can do in these code comments is use the Q colon syntax.

[12:35] And ask any question you want. So it's kind of just like chat GP T within code comments.
So other than that, maybe I stole your thunder. I'm sorry if I did.
What are some of the other? OK.
Some of the other features of Copilot that you use regularly.
Yeah, so I mean going back to your statement about the writing a comment and then having it react to your comment, I think that was like one of the first implementations of the, extension and I had the biggest problem with that you would like write your comment and then expect it to autocomplete some code or do something else and it keeps writing more comments for you.
And I'm, you know, I'm like, no, that's, that's not what I'm wanting.
So that integration I guess is getting better and they're, you know, moving towards like the in line chat feature and the chat sidebar and that kind of stuff. But yeah, it's funny.
Yeah, that was my biggest headache early on it was auto completing your comment.
I was just adding more comments for me like describing what I was trying to get it to do. It was just elaborating on that.
But that's kind of, that's kind of like if you're a pair programmed.
That's true. You've got a thought in your head and you're trying to explain it to the other person, the other person is probably going to ask you questions. Right.
And then at the end of the day I had like, you know, five lines of comments.
That was, it was just like a hallucination of the, the LLM or something.
But uh yeah, so I I didn't use that feature much.

[14:00] But yeah, I mean, I think, you know, as far as the features, I do use how I use Copilot, I use it for writing like boilerplate stuff, just scaffolding out things that I don't wanna have to type out, you know, I know creating new class or something like that and adding all the name spaces and the, classes that have been used and that kind of stuff, you know, it's really good at just kind of spitting out a base like block plug in or something like that if you needed it to.
But how specific in that example, how specific do you have to be with your prompt though? If you, you know, can you just open up an empty file?
You give it a name and say, create a drupal 10 block plug in that does this like how close or, or how specific do you need to be?
You, you can. So yeah, I mean the the more you put in, the more you get out kind of thing.
And then, you know, I think, yeah, if you just wanted to spit out like a, a block plug in, that's just the scaffold of, you know, all the functions that you need to call and the classes you need to extend. It does a really good job at that.
So the obvious, the obvious question is, you know, better than drush generate or roughly equivalent.
Yeah. So, I, I don't have a ton of experience with just Drush generate.
I used to use the drupal cli for generating some stuff, but, I mean, I think it's faster maybe, you know.

[15:23] I don't know, I think II I would use it, you know, it would just be my tool that I go to first.
But yeah, the scaffolding out that kind of stuff you can like put in the criteria of what you want that block to do and, you know, have it generate maybe some of the um config form and that kind of stuff for the block.
But I don't try to do that all at once. Usually I just, you know, I find it creates a lot of junk if you ask too much at once.
So, yeah, in my experience, yeah, I mean, I've, I've gone through it and I'm like, oh, I have to create, you know, this, this thing, I'm gonna give all this context to copilot or GP T or any LLM that I've tried and try to use what it puts out.
And then at the end of the day I spend more time like refactoring and debugging the crap that it spit out.
So, yeah, I mean, anything that's boilerplate, comment related, you know, like just time saving stuff that's my go to currently now, I know it's gonna get better over time. Yeah.
So some of the other features that I've played around with that, I find really interesting exploiting code snippets.

[16:29] I, I've actually had some success with that, but especially like with javascript because I'm not a, you know, huge javascript guy.
So there are definitely times where I have highlighted, uh you know, 1020 lines of javascript and the way I've done it is I, I'll put a comment, you know, after like the last line that I'm interested in and I will write, you know, explain the previous 30 lines of code to me.

[16:54] And it will, it'll spit out, you know, a few paragraphs of, of code and it'll start very generic and then get very specific and it almost sometimes feels like where you have and we all know this type of person where they pretend to know a lot more than they know.
Right. Right. And at some point they're like, I feel like they're just repeating things that I can see as well and they're not really adding much to the conversation.
Yeah. And I'm thankful that, you know, all this stuff's coming out after, you know, drupal eight and everything has, you know, kind of been established because I, I feel like I have gotten drupal seven codes returned, but it's less, I can only imagine if we were like in that, in that.
Yeah, it would be a disaster. But yeah, so I haven't used the explain too much, but that's, that's a super helpful tip.
Yeah, I just discovered uh last week it was that as I said, I, I've been in the habit of highlight a block code and create a comment that, that asked to explain it.
But there is actually you can highlight code right click and then there's a copilot sub menu that pops out that has explained this, which basically does the same thing, same places where that generate docs.
I was gonna say one of the other big features I use for is like, you know, if you, if you write of a block of code and maybe it's a switch statement or an if statement, you know, and it's nested and it's kind of messy like.

[18:19] You know, just highlight it and, and ask co-pilot to refactor it, you know, in a, in a more efficient manner and, and that.

[18:27] Usually works pretty good, you know, or like, you know, it can make, make it a one liner sometimes if you want like to just do it real simple.
Yeah, I find that when I'm writing code, I tend to write very verbose code, like especially with if statements just because I want to be able to like see that flow and I know that there are probably more concise ways of writing stuff like that.
Yeah, I actually haven't thought about trying that to say, you know, refactor simplify this code. That's interesting.
Yeah, one thing I did yesterday or sometime this week was like highlight a class that was using, that wasn't using dependency injection, like it wasn't using the um create, you know, and passing all the things to the constructor.
It was just calling like the static drupal or whatever and highlight that and told it to rewrite, you know, with dependency injection, rewrite class.
And so all my code stayed the same.
I didn't have to worry about it like hallucinating, doing crazy things with it.
Right. And it, and it, yeah, I mean it spit it out.

[19:26] Yeah. So you know, I had to guide it a little bit with the prompt, I think.
But yeah, it did find, yeah, like I told it to use the, I can never remember the name of the class that's uh implementing the interface for a block that does all that I can't, I can't even remember.
So that's why I have copilot container plug in dependency injection, those four words in some order.
I don't know if that's the right order or not.
An example right there is just something that Copilot is, is good for because you, you know, if you can't remember that kind of stuff, you're often uh trying to look through the code or, you know, Googling or whatever.
Now it's just, you know, here it is. I wrote a 15 week course because I couldn't remember stuff like that.
So I went a little bit extreme on that.

[20:12] What's that course? Uh Oh, thank you very much for asking. That's very kind of, it's a professional module development.
Next semester starts soon since I don't know when people are listening to this.
I can't give an exact date.
I say soon, twice a year. Check DrupalEasy.com. Oh my gosh, you're the best.
Hey, have you played with the uh the fix it? There's literally on that same contest menu, right?
Click Copilot. There's a fix this or fix it. Not option.
Yeah, I haven't, I've, I actually, I test it like I literally not, not test as in, I'm going to test it now.
I'm like, but I will and I just tried this again this morning because I hadn't used it in a, in a few weeks where I had a, again, it was just, it was a big long if statement with, you know, Ray was in there.
So I had all kinds of parentheses and square brackets and I randomly removed one of the parentheses from somewhere in there.

[21:08] And then I highlighted that one line and I told Copilot to fix this and, uh, it didn't really fix it, it refactored it, but it was still a syntax error.
So I haven't had great success with that, but that might be, I don't know if that's a newer feature or not because I probably should have me.
I've probably been using this for about a month. Ok.
Yeah. Anything to help with those, you know, things II, I think it's gonna help new programmers that are coming along, you know, that, remember the days of, like being in a, just a text editor.
It wasn't an ID E and you missed a comma or missed some character, you know, and it's like hours of.

[21:46] What is going on. But it's still, it's, it's like an overconfident friend.
That's right. It's, you gotta, you gotta take it out with a grain of salt and, you know, call them on their BS if, if necessary.
Yeah. And it's, I mean, it's kind of interesting, I think because there's like that preconceived thing that people know LL MS are unreliable, like they kind of roll out these extensions and these A I tools half baked, you know, and they get better over time and, but it's kind of funny that, you know, they're very buggy tools.
How about there's a feature to generate tests? We were talking beforehand.
You said you haven't really played with that?
I have not. So sounds like you have, yeah, for the heck of it I generate.
So one of the modules I maintain is a marked down easy module.
It's very, very straightforward implementation of, of mark down in the text filter and we have a service class.
And so I said, you know what, I don't actually have a unit test for one of these methods in the service class in the module.
It's granted a very simple, you know, method.
But so I said, all right. Well, let me highlight this function or put my cursor in the function and use copilots, you know, generate test functionality and see what happens.

[23:00] And I gotta tell you, I was pretty freaking impressed with this one because, it didn't actually create the test in the right place, you know, didn't put it in the test slash unit or test slash SRC slash unit directory.
I think it, it just dumped it in the same directory as my, as my service class.

[23:19] But other than that, it extended the PHP unit, unit based class, unit, test based class as opposed to the drupal.
Right? Which again, two things that were, you know, very easy to fix, especially, you know, I, I have experience writing tests so they were very obvious to me that, oh, it should, obviously, the file should be, should have been created there.
So I moved it, I changed the name space and then I.

[23:44] Extended the proper or the class I wanted and it worked.
That's awesome with just those two little changes. Yeah, it was really impressive.
And I, you know, I, I actually went through the code a couple of times because I didn't believe that it was, you know, I, I really didn't change any code other than that, other than I use PHP Stan a lot.
So there was, you know, and I like to get up, I think I'm working on trying to get most of my code to get past levels or comply with level six PHP Stan and Copilot isn't up to PHP stand level six yet, we'll say.
So there's some additional little work there. But I was actually really excited about that and I'm like, looking for reasons to create more tests with it now.
That's awesome to see. Yeah. And you brought up a good point about, you know, it generated the thing most of the way, but you had the knowledge to know what, where it failed.
And that's a big thing. Like I wouldn't try to use Copilot to write something I don't have any experience with.
And I mentioned this earlier. Like, you know, if you try to get it to do too much, it just, the output is no good.
And then you're sitting there debugging something that is just not right.
You know, and you're wasting a ton of time.
So, if you have that knowledge it's, it's a Swiss army knife.
Yeah. The way I look at it is it, and you can say this for most A I, it, right now we should think about it as making us more efficient, not making us smarter.

[25:12] Right. Yeah, it'll make us faster and it will make, but without like that knowledge to double check our overconfident A I friend, you know, we're probably gonna cause more trouble than it's worth, to be honest.
Yeah. I'm curious to see where that goes in the future. Like how, like when you start learning these things, where, where are you gonna go?
Are you gonna go to the traditional, you know, methods or, or are these things going to start teaching?

[25:37] I'm sure they are. But, you know, it's kinda, kinda interesting early days.
Yeah, a couple more questions. So I, I, you know, I, I have an opinion on this one and I have a feeling you'll probably have the same opinion but in your experience with Copilot, do you find that it gets the drooly stuff?
Um let's say as like when you prompt or you have auto complete does do as good of a job.
Very leading question. Yeah. Yeah, I can tell your opinion already.
Uh No, I mean, I think it does. OK, you know, the core language stuff is gonna be better.
But yeah, there's definitely things that as a drupal developer, you know that what it's returning is either, you know, not the best coding standards for drupal or, you know, there's, there's better ways to do it, more efficient ways.
So, yeah, I think that the whole abstraction of drupal on top of copilot, you kind of have to baby it, at least for now.
Yeah, you mentioned earlier, like the context is really important.

[26:48] Like when you're working and I don't have the answer to this, maybe you do.
But when you're working in a drupal project, it knows about the files you have open, but it doesn't necessarily know about the files you don't have open.

[27:01] But I guess the big question in my head, does it know that you're writing a drupal 10 site?
Like, like how much knowledge does it have? That's a good question.
I mean, I think, um, I usually put that in the, in the prompt.
I think a lot of times like help it along, but, you know, there is going into our next topic, the new features, they just rolled out workspace context in copilot.
So in the chat window, you can type at workspace before your prompt and it will, basically do a search on your workspace for text that matches it's almost like a, just like a, a patchy solar type search.
Like it, it searches all the code, it finds things that might be relevant in your entire project and then it passes those as the context to the LLM.
So that gives you more of like the whole, you know, your trying to find something deep within a project or something that may need more context than just one file.
Are there other little magic keywords like that you said at workspace?
I've never used any of those.
Yeah, I just saw it today actually looking at it and I had, I didn't have much luck with trying it before the call, but I know there's that one, there's a couple other ones but that, that seemed like the biggest new feature that they rolled out because it does have all the.

[28:18] You know, additional context for your, your prompt.
So, is Copilot making you faster, making you making you more efficient?
Because I, I would imagine, I know for me when I first started using it, it probably made me a little bit slower because I'm playing with it so much and I'm trying things, I'm trying to figure out what works and what doesn't work.
But once I know that you've been using it for more than a couple of months, I mean, are you more efficient now? Are you comfortable with it or you?
Yeah, you, you learn what it's good at and what it's not good at and just that the whole scaffolding comments, just the boilerplate stuff that you would normally be typing out, you know, it solves that and that, that's just a waste of time at the end of the day.
So having it do those things is, is awesome.
Yeah. And you know, for someone, you know, someone like both of us who, you know, generally are working as contractors for other folks.
I mean, $10 a month is nothing. Right.
It's, it's nothing if it's going to save you conservatively, you know, an hour a week. Right. Very conservatively.
You know, that, that's well worth it at that point.

[29:24] So, ok, so final question, you know, as someone who's been using it for a while and you, you kind of already answered this. But I want, I want to circle back again like.

[29:33] Where do you kind of lean on it the most when you're, you know, knee deep in a project at, at, you know, 2 p.m.
On a, on a Wednesday and you're just, you know, head down working on something like where, where, what, what are those instances where you are like using it the most?
Yeah, I think back to my original answer. Just the the boilerplate stuff.
Anything that's like related to debugging, I don't use it, you know, Xdebug is still, you know, I, I just don't see that, you know, until Copilot has like Xdebug integration where it's seeing your state change over time within a request.
Like, you know, it's just not a good debug tool, it's a time saving tool for looking up things that you can't remember, right?
Like write a red X to do this or you know, what's the syntax for the state form states, right?
Because I do that like once every three months, I have to write, you know, in the form api the state stuff and I can never remember the syntax and bam, you know, it'll spit that stuff out without having to, go out of the uh the ID E and, and the context switching kills, right?
If you have to, you know, change your train of thought and get into some other tool, Google or whatever it is that it kills your productivity.
So just having it right there is, is invaluable.
All cool. All right. Well, Andy, thanks so much for joining me. Thank you.

[31:03] Thanks for listening to the DrupalEasy Podcast. Don't forget to check out all of our long form drupal training courses at DrupalEasy.com and stay tuned for the next episode of the DrupalEasy podcast.

[31:14] Music.

January 29, 2024