How To Use GitHub Copilot (with Python Examples)

Поділитися
Вставка
  • Опубліковано 9 чер 2024
  • In this video, we'll be taking a look at GitHub copilot - which I think is potentially the most impressive software developer tool to be released in the past year.
    We'll look at what GitHub co-pilot is, how you can use it, and then see some real examples using it Python for general programming, for data science and even for making a game.
    🔗 GitHub Copilot: github.com/features/copilot
    00:00 What is GitHub Copilot?
    02:02 Using GitHub Copilot with Python
    05:57 Solving Leetcode
    10:13 Visualizing stock market data
    15:27 Building a Tetris game
    23:21 Concerns about GitHub Copilot
    25:14 Verdict
    #github #copilot #python

КОМЕНТАРІ • 127

  • @karlfimm
    @karlfimm Рік тому +66

    I'm just starting with Copilot but I'm finding it very useful. I'm a recently retired programmer (40+ years experience) but I tend to do things 'my way'. Suggestions from Copilot often do things in ways I wouldn't normally do myself. Sometimes better, sometimes worse, but a chance to break out of the rut. Copilot is also great for whipping up a quick test routine to exercise code you've written - which means you're more likely to do it.

    • @pixegami
      @pixegami  Рік тому +3

      Glad to hear industry veterans are finding it useful! If you already have a lot of experience and established style, then sometimes Co-Pilot's suggestions can seem a bit mediocre. But if you ever have to work fast in a new framework or language, I find it really helps me to keep moving forward.

    • @2Dimples4U
      @2Dimples4U 10 місяців тому

      Any tips for an older guy to go just started his software Dev career? I sometimes feel like I’m so slow learning compared to these new college grads.

    • @BradBradley-mz4kg
      @BradBradley-mz4kg 10 місяців тому

      Google

  • @konstantinrebrov675
    @konstantinrebrov675 Рік тому +35

    Many job descriptions require the developer to know multiple programming languages, frameworks, APIs, and other features. It takes a lot of time to study and understand all of these software technologies to even get your foot into the door for these jobs. Many positions require you to know a lot of details. For example, different web frameworks might require to achieve the same feature with different codes, they have different ways of approaching the fundamentally same functionality. For embedded systems developers, there are multiple different assembly languages, some with Intel syntax, others with ATT syntax, and also having different registers, and different ways for dealing with digital and analog input/output. Incredible details to master! When studying programming, you have to know the fundamentals, the key concepts. Yet at some point you have studied the concepts of programming, and the algorithms, and data structures ... you reach a point where all that you have to learn are more details about the code itself. You eventually reach a point where more studying will not give you any more in depth understanding, but it is only details that you have to memorize. So automatic programming tools such as GitHub Copilot would be very good for programmers, freeing the programmers from bothering themselves with all the details. It is required of a programmer to know the fundamentals of the programming discipline, and how the systems work, be it web development, embedded development, or phone apps development. But the details can be taken by the Copilot autoprogramming tool. It isn't humanly possible to study and absorb all the information in a reasonable amount of time. So we take care to study only the fundamentals, the main and supporting concepts, but leaving the details to the machine. It's like the principle of abstraction in programming. Like how high level languages and compilers free the programmers from having to hand code every feature in assembly languages. How general purpose logic units free programmers from implementing the algorithms in hardware logic gates, enabling the discipline of programming software to be used at all. So Copilot is the natural continuation of encapsulating low level details into the machine, enabling programmers to be more productive, at least theoretically. If compilers and general purpose logic units did this to the computer programming, Copilot and related autoprograming tools are doing this to what I call "metaprogramming", the process of programming itself, and learning programming. The Matrix movie teaches us, "never have a human do the job which should be done by the machine".

    • @pixegami
      @pixegami  Рік тому +1

      That's the way I see it too - it moves the level of abstractions that software engineers need to deal with. I think this is a good thing.

    • @seatownrocks
      @seatownrocks 8 місяців тому +1

      Having chat gpt generate your comment... no fair! :D

  • @mintifu1658
    @mintifu1658 Рік тому +3

    My ear blown away from how hard this man hit his enter key

  • @Websitedr
    @Websitedr Рік тому +22

    I remember when the argument was using an IDE for typing code was cheating. Only use a plain text editor like notepad or vi they said. The tool doesn't do the job it helps you do the job.

    • @pixegami
      @pixegami  Рік тому +2

      There's always going to be folks who argue against new tools or adoption. It's also sometimes hard to tell apart what is a fad vs what is a truly groundbreaking technology.
      But I'm an optimist, and I'd rather focus on building things than winning arguments! 🛠️

    • @radianta5278
      @radianta5278 Рік тому +1

      actually using a keyboard is also cheating so you should write your code on a paper 😂

    • @MiguelAngel-re6rh
      @MiguelAngel-re6rh 10 місяців тому

      Good old Borland C++ Builder + Copilot... Good !!!

    • @ChannelXY
      @ChannelXY 10 місяців тому

      Actually, using a computer to run a program is cheating. You should always run programs in your head, not only dry run.

  • @kylerrasnick
    @kylerrasnick Рік тому +8

    This was a really helpful introduction to Copilot. Thanks!

    • @pixegami
      @pixegami  Рік тому

      Thanks! Glad you enjoyed it!

  • @christophertreadwell4726
    @christophertreadwell4726 Рік тому +2

    I rarely write comments, but I love the relaxing beat, the explanation, color of the video, and the examples. Thank you so much for this video it is really well polished.

    • @pixegami
      @pixegami  Рік тому +1

      Thank you! I really appreciate you taking the time to write that. It helps to motivate me to make more stuff like this!

  • @davidkovar7486
    @davidkovar7486 Рік тому

    Thank you for your video and the examples you have provided within!

  • @JokerPW84
    @JokerPW84 Рік тому +2

    I haven't used it yet, but your video sure made a point towards me trying it! Thank you! ;)

    • @pixegami
      @pixegami  Рік тому +1

      I think you should definitely at least give it a go. Let me know how you find it!

  • @DouglasFish
    @DouglasFish Рік тому +12

    Thanks for the examples.
    It is making me a little lazier, for sure. I will be sad if it ever goes away. But I also have learned a lot of things that no one would have taught me; or I probably wouldn't have figured out on my own. Analyzing what it feeds me, and figuring out how it works is such a fun adventure every time.

    • @pixegami
      @pixegami  Рік тому +1

      Yeah, same. I felt lazier at first too, but if you look at the 'work' it's doing, it's mostly filling in the blanks for lot of menial tasks (e.g. writing HTTP requests) .
      I'm definitely happy to get that 'time' back to spend on more creative and interesting parts of the project :)

  • @Apple55330
    @Apple55330 7 місяців тому +1

    Awesome! Thanks for sharing your insights!

    • @pixegami
      @pixegami  6 місяців тому

      Glad you enjoyed it!

  • @rasfuranku
    @rasfuranku Рік тому +1

    Insightful!

  • @simonmescal9136
    @simonmescal9136 Рік тому +2

    This is a very good video indeed. Thanks

  • @davidm2.johnston684
    @davidm2.johnston684 Рік тому +1

    Thanks for the demo!

    • @pixegami
      @pixegami  Рік тому +1

      You're welcome!

    • @davidm2.johnston684
      @davidm2.johnston684 Рік тому

      @@pixegami Sure man! Actually I just got a subscription as a result, and I'm trying it right now. One thing it doesn't really support is tweaking an existing code base, as it can write additional code but can't modify existing code. Or maybe there's a trick to get it to do that, that I haven't figured out yet (such as marking the old code as deprecated and suggesting in a comment that you're rewriting said code). Or maybe that's a feature they may add later on.
      Well, I'll see if it feels like a 25% speedup in the weeks to come ^^ but like you said, even lower than that would still be pretty cool

  • @fsaforosaforo6338
    @fsaforosaforo6338 11 місяців тому +1

    Very cool and useful video! I am a novice in the programming game, this video shows me how copilot could help me broaden my skills .... sorta like a tutor who is available whenever I need it. Thanks for sharing. Flo

    • @pixegami
      @pixegami  10 місяців тому

      Exactly right. Just be-careful of relying on it too much without understand what it's suggest you!

  • @WhiteSiroi
    @WhiteSiroi Рік тому +1

    thank you so much, very useful tut

    • @pixegami
      @pixegami  Рік тому +1

      Glad it was helpful!

  • @TORstein-Bboudelaire
    @TORstein-Bboudelaire Рік тому +3

    It's amazing to learn, helps a lot. He write the comments too!

    • @pixegami
      @pixegami  Рік тому +1

      Yeah, it's very helpful. But you always need to audit what it suggests - sometimes it's the wrong thing!

  • @hedgefund996
    @hedgefund996 Рік тому +2

    Awesome Content, Thanks

  • @codecaine
    @codecaine Рік тому +1

    Excellent review

  • @bgwg80
    @bgwg80 Рік тому +1

    I found useful to provide the contexts of what I intend to do to copilot by writing comments before trying to write any codes. So, I usually write comments, hit enter, then at the next line, copilot provides a code snippet sometimes the whole chunk, the other times, line by line. Then, I tweak the logic and refine coding style. I iterate this process repeatedly. It's definitely not perfect but I type a lot less nowadays to get the job done with the same level quality that I've been practicing for writing codes. It's definitely a great "assistance."

    • @pixegami
      @pixegami  Рік тому

      Yeah that's exactly what I do as well. Another thing that has worked well for me is to write all the function signatures/returns first, or the datatypes first, and let it fill in the logic.

  • @Rider0fBuffalo
    @Rider0fBuffalo Рік тому +2

    I have struggled to use Copilot usefully. I usually try to use it via a comment prompt - like "filter a list foo for items where status is 'done'" and it doesn't output anything or it outputs too much unrelated code (even with such a simple prompt). However Chat-GPT is incredibly good at doing this. So I was watching this video to try and figure out how to employ it better, but I didn't see anything different from how I use it. I try to comment all my code to give it more context, and that helps a little.

  • @LucijaC
    @LucijaC Рік тому +1

    Thanks for the great intro video! What VSCode theme do you use, it is pretty neat?

    • @pixegami
      @pixegami  Рік тому

      I use “Monokai Pro” 😁

  • @boomerangfish3558
    @boomerangfish3558 Рік тому +1

    Pretty great video

  • @ph3086
    @ph3086 Рік тому +3

    Thanks for the video! Bit of irrelevant quastion: Which vs code theme are you using?

    • @pixegami
      @pixegami  Рік тому +1

      Thank you! I used Monokai Pro in VSCode. I also sometimes use "Nord".

  • @annacheng2415
    @annacheng2415 Рік тому

    It's very useful tools for me, I am a student of someone University, It really give me many greate recommend which will enhance my programing skill.

  • @Shiffo
    @Shiffo Рік тому +6

    As a Finance guy that has been using and learning Python on the side for the past 5 years. I have to say that using ChatGPT has made me use Python a lot more and has made me learn a lot quicker about the types of code I can use.

    • @pixegami
      @pixegami  Рік тому +1

      Sounds like a great use case for it. And I think it’s going to be especially helpful to folks who aren’t full time programmers, but want to eventually tap into coding or automation.

  • @cloudzero2expert
    @cloudzero2expert Рік тому +1

    Thank for the video. It was funny to hear "let's do a real problem, leetcode", kk.

    • @pixegami
      @pixegami  Рік тому

      😂 Now that you mention it, it is pretty ridiculous...

  • @xugefu
    @xugefu 4 місяці тому +1

    Thanks!

    • @pixegami
      @pixegami  3 місяці тому

      Wow! Thank you so much :)

  • @nkristianschmidt
    @nkristianschmidt Рік тому +3

    It's a good trade-off, to have time for design and strategy

    • @pixegami
      @pixegami  Рік тому

      Exactly - less time spent on boiler-plate work, and more time for interesting and creative work.

  • @chris9352
    @chris9352 Рік тому +7

    I don't get why some devs are against this!
    When you think about it, everybody uses stack overflow time to time when they are stuck!
    GitHub copilot is simply saving you time that you would have spent googling the same things anyway! So, let not be hypocrites here!
    The only use case where this might be really really bad, is if you're new to coding and still need to grasp important fundamental concepts of computer programming.
    Because you need to be at least able to read and 100% understand the codes that GitHub copilot generate, otherwise you're just shooting yourself in the foot!

    • @music_news888
      @music_news888 Рік тому +2

      well, many programmers using lib that they don't understand at all, so...

    • @pixegami
      @pixegami  Рік тому +1

      The main arguments I've heard were that it makes you a worse coder, or there could be license violations in your code. You also grant GitHib (Microsoft) access to your source code, which is a major privacy concern - especially if you have trade secrets in the code.
      All seem fair concerns, although not as convincing in smaller projects, start-up environments, and individual learning/development.

    • @innocentiuslacrim2290
      @innocentiuslacrim2290 Рік тому +1

      I would argue that something like this is great for beginner programmers as they often tend to be stuck behind syntax issues and get discouraged from continuing prigramming. This can help them pass that hurdle and to continue learning.

  • @JT-zl8yp
    @JT-zl8yp Рік тому +2

    Thanks for making this video.....Do you use github copilot at your work ?

    • @pixegami
      @pixegami  Рік тому +2

      I work at a Microsoft competitor, so GitHub Copilot isn't a fit for my work. But I do enjoy it for personal projects!

    • @JT-zl8yp
      @JT-zl8yp Рік тому

      @@pixegami Cool....keep making more videos with copilot

  • @immortalsun
    @immortalsun Рік тому

    This is pretty interesting, but I have encountered a problem where it stops suggesting past quotation marks.

  • @ArchanaRaghupathy
    @ArchanaRaghupathy Рік тому +9

    I think it should be part of development as more time is spent in trivial tasks

    • @pixegami
      @pixegami  Рік тому +2

      I agree... It's good for learning new languages and frameworks too.

  • @jimmysaxblack
    @jimmysaxblack Рік тому +1

    thanks !!!

  • @epicflails5471
    @epicflails5471 Рік тому +1

    whats the music used in the video? Great video btw

    • @pixegami
      @pixegami  Рік тому

      Thanks! I don't remember which track I used for this (I'll remember to note it down for my future videos), but it was something from artlist.io/royalty-free-music

  • @Pinefenario
    @Pinefenario Рік тому +2

    Good video about copilot! But shouldn’t you blur the api key?

    • @pixegami
      @pixegami  Рік тому +3

      Yup! In this case I believe that API key was public and free - but even then, it's probably a good idea to blur it.
      In additional I also delete and rotate every API key I use during video recordings.

  • @maryam4071
    @maryam4071 3 місяці тому

    How are you are highlighting it? with what shortcut key? I am not able to see inline suggestion on windows

    • @pixegami
      @pixegami  3 місяці тому

      Hmm, when I use it normally, I don't really press anything beyond Tab or Escape. But here's a list of all the shortcut keys for different OS: docs.github.com/en/copilot/configuring-github-copilot/configuring-github-copilot-in-your-environment

  • @user-km4tx4hx6y
    @user-km4tx4hx6y 7 місяців тому

    how do you add py files to azure?

  • @user-te1de5kl1q
    @user-te1de5kl1q 11 місяців тому +1

    Can you tell me what theme do you use in vscode ?

    • @pixegami
      @pixegami  10 місяців тому

      I'm using monokai.pro/

  • @Liquidduck
    @Liquidduck 11 місяців тому

    I have no idea what I am talking about but do you think that it used names with the letter J as that is the 10th letter in the alphabet and you mentioned 10 in your prompt.

    • @pixegami
      @pixegami  10 місяців тому

      I don't think so, I think it's mostly because the first example name I used started with "J" and it tried to repeat that pattern.

  • @martinurinovsky7594
    @martinurinovsky7594 Рік тому +1

    How do you make your vs code look that clean?

    • @pixegami
      @pixegami  Рік тому

      Hmm, for the tutorials I close the built-in terminal. I also disable the minimap: code.visualstudio.com/docs/getstarted/userinterface#_minimap
      Is there something else you feel makes it look "clean"?

  • @karrde666666
    @karrde666666 Рік тому

    Obsolete now that chat gpt can do english to entire pages of code?

  • @patrick1532
    @patrick1532 Рік тому +1

    I'm going to try it because it's free with my student account but considering the first suggestion it made in this video was to use a redundant list comprehension that could just be list(range(100)) I am going to be very careful

    • @pixegami
      @pixegami  Рік тому +3

      Try it out! I especially recommend using it on a project where you are using a new framework or a new language.
      As with any tool, it is always good to be careful and critical about how you use it, and Co-Pilot is no different. However, I think your premise about its suggestion being 'redundant' is misguided.
      1. If you already have code precedent in your file that prefers "list(range(...))", then it will probably learn that and suggest it.
      2. If you have no style precedent set, it will suggest what it thinks is the most "common" way to solve the problem. What is suggests is a reflection of what the developer community has applied in practice - and even if it's sub-optimal, there is value in conventionality (especially if you work in a team).
      3. Both list(range(...)) and list comprehension solve the problem. Choosing one over the other is an optimization matter, but optimization was never one of Co-Pilot's value propositions. On the criteria of solving the problem and saving developer time, it still delivers.

    • @patrick1532
      @patrick1532 Рік тому +1

      @@pixegami Thanks for the reply, I appreciate the well thought out response! I hadn't thought about it that way, I suppose list(range()) may actually be more ambiguous than the comprehension to someone not super familiar with python, and less natural to someone coming from another language. I'm no expert but I have enough experience with python that I had difficulty seeing that utility.

  • @weirdmaninshirt
    @weirdmaninshirt 11 місяців тому +1

    First week in and I'm not a fan. It can make simple functions sure, but once you are writing something more complex it just starts suggesting I call functions that don't exist on the specific type. very type unaware in Typescript. Noticed similar problems in C++. My main issue is once it suggests some trash it disables the regular autocomplete on VSC, so it just slows me down. Not giving up on it yet, but I'm very sceptical it will get better.

    • @pixegami
      @pixegami  10 місяців тому

      I've run into that issue with it disabling the regular autocomplete too (which in some cases is what I need). I think there needs to be an easy way (or a hotkey) to switch it off somehow.
      It's most useful if you need to do something small in a domain you're unfamiliar with - e.g. a specific regex expression. Or when you have tedious (but simple) code that needs filling out.

  • @user-ph3rt2pv9t
    @user-ph3rt2pv9t Рік тому +1

    😮

  • @jobsnike3776
    @jobsnike3776 Рік тому +1

    whether github copilot upload my db password of properties?

    • @pixegami
      @pixegami  Рік тому

      Copilot can see all of your code-base. It's unlikely secret data would get leaked because that would be the end of Copilot. But it's probably good to secure all your secret data even from Copilot anyway (e.g. with environment variables or using a secret manager) and limiting the damage that exposed API keys and passwords can do from the backend.
      You don't have to be paranoid about it, but do be prepared just in case.

  • @tranthanhbao9978
    @tranthanhbao9978 Рік тому

    what theme you are using

  • @BlackTigerAP
    @BlackTigerAP Рік тому

    Please remind me something... Why exactly should I "code faster"? I'm paid for result, not for how quickly I type.

  • @MrStarz-jh7wl
    @MrStarz-jh7wl Рік тому +1

    2:44 wdym by tapping through them?

    • @pixegami
      @pixegami  Рік тому

      GitHub Copilot generates multiple suggestions, and there are hotkeys you can use to tap (cycle) between them: docs.github.com/en/copilot/configuring-github-copilot/configuring-github-copilot-in-visual-studio-code#keyboard-shortcuts-for-github-copilot

  • @kck001
    @kck001 Рік тому

    Can support Traditional Chinese language or not?

  • @MyBrianBailey
    @MyBrianBailey Рік тому

    you have to REALLY REALLY want to make a Tetris game even with copilot lol lot's of patience to create that game

  • @joelboardgamerpger5393
    @joelboardgamerpger5393 Рік тому +1

    what is if ___name__ == '__main__'?

    • @pixegami
      @pixegami  Рік тому

      So I did a search on Google and the definition that came up was: "A Python programme uses the condition if __name__ == '__main__' to only run the code inside the if statement when the program is run directly by the Python interpreter. "
      But that's a bit of a technical explanation. So to explain it in my own words-you use it so say "only run this code if I'm running THIS file directly." Anything *outside* that condition is actually run whenever the file is loaded (e.g. if you wanna import it into another file), so if you DON'T want stuff to run there, but only when you directly run that program, that's when you use the condition.

  • @jtvalente
    @jtvalente Рік тому +1

    How does this differ to chatgpt?

    • @pixegami
      @pixegami  Рік тому +2

      Good question. I just had a look at ChatGPT and made a first look video here: ua-cam.com/video/EG_UqnMV7Wk/v-deo.html
      In short, I think CoPilot is better for me. ChatGPT is good at the first (general) phase of a project, or for debugging. But CoPilot works better once the project gets going.

    • @JokerPW84
      @JokerPW84 Рік тому

      As far as I know (and I might be wrong at it), ChatGPT was trained using human text, while CoPilot was trained using code samples from GitHub. So, it should be a more specialized tool. =]

  • @FreeEasyAI
    @FreeEasyAI 3 місяці тому +1

    Seems you should be a lot more than 25% faster, given that AI does most the grunt work of typing. For example, telling copilot to "write an html page with header, nav, main, and footer sections", it will type all that code faster than you could type the first tag. It's more like 25 times faster, not 25% faster. How about "write a pytorch image classifier"? Takes it a few seconds to type it all.

    • @pixegami
      @pixegami  3 місяці тому

      Depends on what you measure with that "25%". I think if you go by typing speed alone sure. But that balance will change as the scope of project changes. For example, if 80% of your work is figuring out how the design and structure of your code, then GitHub Co-Pilot isn't making your whole project faster.
      For me, when I measured a typical project I work on, it was about a conservative 25% boost (which is quite incredible already), for others it may be more or less.

  • @insertoyouroemail
    @insertoyouroemail Рік тому +1

    "Making you worse at coding" is an interesting and not a new argument. The same was said about IDE's in general in the past.

    • @pixegami
      @pixegami  Рік тому +1

      Yeah exactly. It's only concern if your goal is to be a 'coder' - but instead, I really think all 'coders' should aspire to be a 'builder'. 🛠️

    • @insertoyouroemail
      @insertoyouroemail Рік тому

      @pixegami a craftsman even :) I agree completely. 👍

  • @Alex-kr7zr
    @Alex-kr7zr Рік тому +6

    Another concern that absolutely should mention is legal concerns. Github Copilot was trained on open source software with various licenses, a lot of them state that you at least need to give attribution to the author. So basically you might use illegal code in your software. Lawsuits are already running. Wouldn't use the co-pilot generated code in any business setup for that reason, maybe as smart documentation tool, but not for generating production code.

    • @pixegami
      @pixegami  Рік тому

      You're right about that being a concern and I definitely should have mentioned it. I wasn't aware of the class action against OpenAI at the time of making the video.
      I'm eager to see how the lawsuit settles. But if OpenAI and Microsoft win, I struggle to see how future plantiffs will prove (or even discover) cases of "stolen code" unless it is both public and verbatim.

    • @Alex-kr7zr
      @Alex-kr7zr Рік тому +1

      @@pixegami Yes, you are right, it's probably hard to prove that you have been using copilot in closed source software. Even in open source software it's hard unless it copies pieces 1:1, but it most likely only does that for very simple solutions, so that could also come from the docs of the API for example. I'm still curious about the outcome of the lawsuit. I'm pretty sure that the field of AI will become a lot more regulated in the future. GitHub/M$ has already responded by adding a feature to deactivate suggestions which contain public code pieces, most likely other AI assistants will have a similar feature soon. Also, we might see OSS licenses covering AI at some point. Maybe a GPLv4 or something like AGPL, but for AI.

    • @pixegami
      @pixegami  Рік тому

      Yup, I reckon they’re be some back and forth but things will eventually find a sensible middle ground.

  • @michaeltse321
    @michaeltse321 Рік тому +1

    My bposs saw this video and offered me a 25% pay cut - lol

    • @pixegami
      @pixegami  Рік тому

      Unacceptable! They should've offered you 25% pay increase since that's how much more productive you'll become.

  • @nadzhafox
    @nadzhafox Рік тому

    For my ticktok brain where long introduction

  • @thechessmaster9291
    @thechessmaster9291 4 місяці тому +1

    Copilot presented you with a full code ... , why do you want to invent the wheel again ????? wtf .....

    • @pixegami
      @pixegami  3 місяці тому

      Not quite sure what you mean here...

  • @lookingjust987654321
    @lookingjust987654321 Рік тому +1

    Colleague of mine suggested using it to write tests. Amazing use of copilot

    • @pixegami
      @pixegami  Рік тому

      Yes! I've been using it to write a few tests and it's pretty good at predicting my intent and saving time.