Check out a free preview of the full Developer Productivity course

The "Snippets & GitHub Co-Pilot" Lesson is part of the full, Developer Productivity course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen briefly demonstrates using snippets to help autocomplete code and discusses GitHub Co-Pilot as a future prospect for replacing code snippets with AI assisted programming. GitHub Co-Pilot searches through all of GitHub to suggest an autocomplete for the user.

Preview
Close

Transcript from the "Snippets & GitHub Co-Pilot" Lesson

[00:00:00]
>> First, there's this thing's called snippets, I am sure most of you have used some form of snippets in vscode, right? We're gonna just do a quick example, I know they're available in IntelliJ, vscode, emacs, vim, they're all over the place, you can definitely use these. So if I were to come in here and just type in the word, function foo and do this.

[00:00:20]
I could type all of that in there, took me a little bit of time, or I could just type in fn and use this little snippet program. And then go foo, hit tab I don't want any of those, hit tab. And then there you go, I'm now in the body and I can start typing.

[00:00:33]
Snippets, they're pretty cool, right? They're pretty neat, but for the most part, I actually don't really like snippets too much, they're great for learning a language. Hey, I wanna do a for loop and go, and I don't really know how to do a for loop and go, type in for, look for the snippet auto complete, use that as a method of learning.

[00:00:51]
Great but it's not, I feel snippets are just simply a stepping stone to something better. Ultimately I do think there is something better,it's not available for everybody and I think it's coming and I think we're all gonna use it. I think by 2024 there will be most developers using some form of this, I know that's a pretty big guess, two years, maybe it's gonna be five years.

[00:01:14]
But of course, what is it? It is gonna be GitHub Copilot, I think something like a GitHub Copilot is gonna be a part of every person's job being able to do AI assisted programming. And if you haven't had the time to use it or even look at it, we're gonna take a brief little look at it right now.

[00:01:28]
So I'm gonna actually just touch a file in here, let's call it, make-a-game, I'm gonna do something really simple, and ts, there we go. And let's go over here, just to kinda make it easy, type script is its best language. Gosh, I agree to these additional telemetry. My goodness, my goodness.

[00:01:47]
Not a fan of telemetry but hey, some people like giving all their information to other people, so GitHub Copilot right here, ready to rock. For those that don't know anything about GitHub Copilot, it uses the entirety of GitHub, scans through things. It uses another, that open AI, Codex, whatever it's called, to kind of generate this smart item to be able to give you suggestions and some of the suggestions are pretty dang good.

[00:02:15]
Actually here, this is what I was doing, create a matrix, let's see a translation matrice, I wanted to do something that was a little bit easier. Translation matrice homogenous four by four. Function, createTranslationMatrix. There you go, there we go, we got a createTranslationMatrix, it's obviously doing something a little bit goofy, it's putting the values over here as opposed to here.

[00:02:40]
It has a rotation in the matrix but it's able to generate these things pretty quickly. And you can kind of, you know, okay now we gotta create that mat4 class. Create mat4 class, From values. Yeah, that's exactly how we used it elsewhere. And there we go. And there we go.

[00:03:11]
It effectively worked, now we just gotta create the constructor. It's kind of interesting how it's doing this, notice how it's kind of programming. It definitely did exactly what it said it was going to do, just a little bit goofy. How do you wanna do this? How do you wanna do this?

[00:03:28]
What a funny way it did it. It's obviously not that great. You can see that it's doing things in kind of a really goofy not very great matrice way, but nonetheless, it's actually attempting to create these things on the fly and eventually you'll actually get something that works.

[00:03:43]
I was able to make a couple games that worked fairly successfully like this and so this is really where I think the future will ultimately go. Right now it's like a toy. You use it, it fails all the time, but it's only gonna keep on getting better and better and better.

[00:03:58]
And I do think one day it will be quite incredible because you're gonna be typing, it's gonna be able to A, understand your project which there's a lot of questions about, do private companies want GitHub to understand the project, blah, blah? But barring all those things aside, ultimately, if this thing can make really great like, hey, by the way, this code already exists in this one spot, you would have never known that.

[00:04:18]
You would have created duplicate code, it's gonna be able to spot so many things that just tools aren't easily able to spot. And I do think one day this will be really incredible. Right now it's kind of in its infancy, It's in its technical preview. Sometimes it's awesome, sometimes it's ridiculous.

[00:04:34]
Sometimes you can get it to say funny things like, tell me a joke, and then it's gonna come in here and say, tell me a joke. And what are you gonna do? Knock knock, who's there? Java, Java who? Java, it's me, look at that, how great is that?

[00:04:47]
How great is that knock knock joke? It just gave me a joke right then and there using alert boxes but nonetheless, I find this thing to be pretty interesting. It gives you a whole new perspective on how some things could be done and some things are really useful.

[00:05:00]
Things that have really concrete values that you know probably exists a lot out there they can do really quickly. Some things, it doesn't do very good right now. Create a rotational, watch, matrix, there we go. Create rotation matrix and it's gonna do all these nice little things, I don't even know where it's going right now.

[00:05:20]
Let's see where it goes, does it? Let's undo this because it's obviously bad. Four by four homogenous, there we go. Let's see if we can get it to do that. All right, yes, yes, yes. Do it, my goodness that is looking potentially incorrect. This is looking very incorrect, interesting.

[00:05:42]
So that time I couldn't do it, I've actually written a few programs that have got it completely correct. It just is a really funny thing right now because it's so untapped right now, but I do think that there's gonna be a moment within the next couple years that we are all using some version of this.

[00:05:59]
And I do think it's significantly better than snippets, because snippets only allow for so much. You can look through the suggestions. You can look through all the suggestions, I was just taking the first one but nonetheless it's actually rather incredible what it can do. I mean, the fact that it can even get to that point for me is already just an amazing experience.

[00:06:22]
I don't know what it's going to be like, but I do know a lot of people always worry, I hear a bunch like, hey, is Copilot gonna take our jobs? I don't think Copilot's gonna take people's jobs. But I think people who know how to use Copilot in the next couple years are gonna be sought after engineers, people that know how to take advantage of these new tools.

[00:06:40]
Because you're just gonna be able to generate a lot of things that can kinda self heal themselves. These AIs, these robots, as they get more and more experience, they're just gonna know how to do things better faster than we will ever be able to do. You could have a million line codebase and say a summing function already exists, but you couldn't find it.

[00:06:58]
You could imagine that you'd start typing the code, it's like, hey, already exists here, go check this out, jump, boom, you just import it, then it just knows all the things. And the skill gap is definitely, so someone's mentioning skill gap, I think skill gap is gonna become very interesting.

[00:07:13]
Because the faster and better you're able to use these tools, I think it's gonna greatly change what type of engineer you are. And so I'm not someone that likes to reject cool new technologies just because they're, I mean, obviously this example kind of stunk. I did this literally last week and it was spot on.

[00:07:29]
It was so ridiculous to the point where even when it was comparing input, it was like player one wins. I was like, correct is like Player Two Wins, is that correct? Then it did an L statement, I'm like, all right, it's doing an L statement, it was like, it's a tie and I never put anything in there about doing a tie.

[00:07:44]
It knew from all the other stuff that it could put in a tie, it was incredible. It's very hard to make this thing always work consistently but I do think that there's a lot of room for this thing. It's gonna be really cool, I'm very excited about it at least, minimally

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now