Tips & Tricks: Get the Most Out of GitHub CoPilot | DevReach 2023

Progress Telerik
22 Nov 202359:42

TLDRIn the engaging session from DevReach 2023, Todd England from Microsoft's Cloud Advocacy team introduces GitHub CoPilot, an AI pair programmer designed to enhance coding efficiency. The talk covers the basics of how CoPilot functions using large language models to predict code completions. It emphasizes the importance of providing context for CoPilot to offer accurate suggestions, such as keeping relevant files open, writing clear comments, and using meaningful variable names. England demonstrates CoPilot's capabilities in real-time, showcasing how it can help write basic code faster, remember coding details, extend and refactor code, explain unfamiliar code, understand and fix errors, and even add tests to projects. The session also highlights the iterative process of refining CoPilot's suggestions to achieve desired outcomes and the integration of CoPilot with development environments like Visual Studio Code and Visual Studio. The summary underscores the tool's potential to improve developers' productivity and experience, positioning CoPilot as a valuable asset rather than a job replacement.

Takeaways

  • ๐ŸŒŸ **GitHub CoPilot as an AI Pair Programmer**: GitHub CoPilot acts as an AI pair programmer, assisting developers by writing code, explaining code, and suggesting next steps based on the context provided.
  • ๐Ÿ“š **Large Language Models (LLMs)**: CoPilot is powered by LLMs, which predict what code comes next based on patterns in vast amounts of training data.
  • ๐Ÿš€ **Accelerating Development**: It helps in accelerating the coding process, especially for basic code writing, by providing quick suggestions and completions.
  • ๐Ÿ” **Understanding Limitations**: CoPilot has limitations, such as not being a compiler, not remembering past interactions, and requiring clear context to provide accurate suggestions.
  • ๐Ÿ’ก **Context is Key**: Providing good context is crucial for CoPilot to give relevant suggestions. This includes open files, top-level comments, and meaningful variable/function names.
  • ๐Ÿ”ง **Iterative Improvement**: Developers should trust but verify CoPilot's suggestions, iterating over them to refine the code to meet specific needs.
  • ๐Ÿ”— **Integration with IDEs**: CoPilot integrates with various IDEs like VS Code and Visual Studio, enhancing the developer's existing workflow with its AI capabilities.
  • ๐Ÿ› ๏ธ **Refactoring and Code Understanding**: CoPilot aids in refactoring existing code, understanding unfamiliar code, and even generating tests, which can improve code quality.
  • ๐Ÿ“ **Documentation and Comments**: Encourages better coding practices, including the use of comments, which also help CoPilot provide more accurate assistance.
  • ๐Ÿ”„ **Handling Errors and Debugging**: CoPilot can assist in understanding and fixing errors, including during the debugging process, by explaining exceptions and suggesting solutions.
  • โžก๏ธ **Future Capabilities**: CoPilot is set to introduce more features, such as aiding with pull requests, indicating a path of continuous improvement and expansion of its capabilities.

Q & A

  • What is the main topic of the talk at DevReach 2023?

    -The main topic of the talk is 'Tips & Tricks: Get the Most Out of GitHub CoPilot', which focuses on how to maximize the use of the AI pair programming tool, GitHub CoPilot.

  • Who is the speaker at the beginning of the transcript?

    -The speaker is Todd England, who is part of the Cloud Advocacy team at Microsoft.

  • What is the significance of the year 2013 in the context of the talk?

    -The year 2013 is significant because it was the year of the first DevReach conference that Todd England attended and spoke at.

  • How does GitHub CoPilot assist developers in their coding process?

    -GitHub CoPilot assists developers by predicting code completions based on the context provided by the developer, acting as an AI pair programmer that can help write code, explain unfamiliar code, and even add tests to a project.

  • What are some ways to provide better context to GitHub CoPilot for improved suggestions?

    -To provide better context to GitHub CoPilot, developers should keep relevant files open, use top-level comments to describe the goal of the file, include meaningful names for variables and functions, add specific comments for targeted completions, and provide sample code or examples.

  • What are the limitations of GitHub CoPilot that developers should be aware of?

    -GitHub CoPilot has limitations such as being based on a fixed point in time for its training data, not being a compiler to check the correctness of code, and not being able to read the developer's mind, thus requiring clear and specific prompts to provide useful suggestions.

  • How does GitHub CoPilot handle the token limit in its responses?

    -GitHub CoPilot has a token limit for the context it can process and the responses it can generate. Generating a large amount of content, like a hundred lines of Lorem Ipsum, is not efficient and not what the tool is optimized for due to this token limit.

  • What is the role of the developer when using GitHub CoPilot?

    -The developer acts as the 'pilot', guiding the AI by providing context, verifying the suggestions given by CoPilot, and iterating on the code until the desired result is achieved.

  • How can GitHub CoPilot help with refactoring code?

    -GitHub CoPilot can assist with refactoring code by providing suggestions to change code patterns, such as converting function names to camel case, based on natural language prompts from the developer.

  • What are some of the upcoming features for GitHub CoPilot?

    -Upcoming features for GitHub CoPilot include integration with pull requests to help accelerate the process of doing quality pull requests, and more functionalities that will be announced on github.com/features-preview.

  • How can developers stay updated with the latest tips and tricks for using GitHub CoPilot?

    -Developers can stay updated by following the vscode YouTube channel for short video tutorials, checking the GitHub Features Preview page, and participating in CoPilot Adventures for hands-on practice.

Outlines

00:00

๐Ÿ˜€ Morning Greetings and Introduction to GitHub Co-Pilot

The speaker, Todd England, starts the session with a warm welcome and light-hearted remarks about the audience's possible activities the night before. He introduces the topic of the day: tips and tricks for getting the most out of GitHub Co-Pilot, an AI pair programmer. Todd mentions a past event, Dereach 2013, and engages the audience with a selfie to continue a new DevReach tradition. He then provides a brief introduction about his role at Microsoft as part of the Cloud Advocacy team and encourages the audience to connect with him on social media for further discussions.

05:00

๐Ÿ” Understanding GitHub Co-Pilot and Its Limitations

Todd explains the underlying technology of GitHub Co-Pilot, which is based on large language models (LLMs). He clarifies that these models work by predicting what comes next based on existing code patterns. The speaker also discusses the limitations of GitHub Co-Pilot, such as its training data constraints, the fact that it is not a compiler, and its inability to read the user's mind, emphasizing the need for context when using the tool.

10:02

๐Ÿ“š Providing Context to GitHub Co-Pilot for Better Suggestions

The paragraph focuses on the importance of context when using GitHub Co-Pilot. Todd outlines several ways to provide context, including keeping relevant files open, using top-level comments to set goals, including in-file references, using meaningful names, writing specific comments, and providing sample code. He emphasizes that good coding practices and clear communication of intent to the AI are crucial for receiving accurate and useful suggestions.

15:03

๐Ÿ’ก GitHub Co-Pilot's Versatility in Assisting Developers

Todd elaborates on the various ways GitHub Co-Pilot can aid developers, such as writing basic code faster, helping to remember coding details, extending and refactoring existing code, explaining unfamiliar code, understanding and fixing errors, and even adding tests to a project. He encourages the audience to explore these capabilities and to stay tuned for future functionalities.

20:05

๐Ÿ–ฅ๏ธ Live Demo: Using GitHub Co-Pilot in GitHub Code Spaces

The speaker transitions into a live demonstration using GitHub Co-Pilot within GitHub Code Spaces. He navigates through a simple script file and provides tips on how to use GitHub Co-Pilot effectively. The live demo showcases the process of receiving and accepting suggestions from the AI, verifying the code's correctness, and iterating on the suggestions to achieve the desired outcome.

25:06

๐Ÿ”ง Iterating and Trusting But Verifying GitHub Co-Pilot's Suggestions

Todd demonstrates the process of iterating on GitHub Co-Pilot's suggestions to refine the code. He emphasizes the importance of not blindly trusting the AI and instead using developer knowledge to verify the suggestions. The live coding session continues with experimenting with different prompts to generate a function that removes HTML tags from a string using regular expressions.

30:07

๐Ÿ“ Documenting Code and Adding Tests with GitHub Co-Pilot

The speaker shows how GitHub Co-Pilot can be used to document code and add tests. He uses the 'slash' commands in the inline chat to generate documentation for a function and to create test cases for the script. Todd also discusses the process of installing a testing framework and running tests, all within the integrated development environment (IDE).

35:09

๐ŸŒ Creating a CSS Stylesheet with GitHub Co-Pilot

Todd moves on to demonstrate creating a CSS stylesheet with the help of GitHub Co-Pilot. He uses comments within the CSS file to guide the AI towards creating styles for the header and footer. The speaker also addresses the limitations of generating large amounts of content like Lorem Ipsum through GitHub Co-Pilot and instead uses a more efficient method within the editor.

40:10

๐Ÿ”„ Refactoring Code and Adding Features with GitHub Co-Pilot

The paragraph covers how GitHub Co-Pilot can assist in refactoring code and adding new features to an existing project. Todd uses the chat feature to ask for help in making the main content area scrollable and the footer always visible. He also discusses the importance of context when using GitHub Co-Pilot, showing how the tool's suggestions become more accurate when the relevant files are open.

45:12

๐ŸŽจ Applying CSS Features with GitHub Co-Pilot's Assistance

The speaker demonstrates using GitHub Co-Pilot to apply CSS features such as linear gradients and transitions. He uses comments within the style tags to prompt the AI for specific CSS effects and accepts the suggestions after reviewing them. The paragraph also highlights the importance of iterating on the code and using the AI's chat feature for clarification and assistance.

50:14

๐Ÿ“ Adding a Task Service to an Existing Project

Todd illustrates how to add a new service to an existing project using GitHub Co-Pilot. He emphasizes the impact of context by comparing suggestions made with and without an open file that relates to the project. The speaker shows how the AI can generate code that aligns with the project's conventions when given the proper context.

55:15

๐Ÿ› ๏ธ Refactoring and Debugging with GitHub Co-Pilot

The paragraph concludes with a demonstration of using GitHub Co-Pilot for refactoring code and debugging. Todd uses the inline chat to request code that will cause a deliberate crash in a console application. After the crash, he shows how to use the AI to understand and resolve the exception that occurred, showcasing the tool's capabilities in assisting with debugging sessions.

๐Ÿš€ Recap and Future of GitHub Co-Pilot

In the final paragraph, Todd recaps the key points discussed during the session, including the importance of using single, specific, and short prompts, trusting but verifying the AI's suggestions, and the critical role of context. He also looks to the future, mentioning upcoming features for GitHub Co-Pilot and encouraging the audience to explore the tool's potential through features like GitHub Co-Pilot for pull requests and Co-Pilot Adventures. Todd concludes by reinforcing the idea that AI tools like GitHub Co-Pilot are meant to assist, not replace, developers, and that understanding and effectively using these tools leads to more productive and enjoyable programming.

Mindmap

Keywords

๐Ÿ’กGitHub CoPilot

GitHub CoPilot is an AI-powered programming assistant that works alongside developers to enhance their coding workflow. It uses large language models to predict and suggest the next lines of code based on the context provided by the programmer. In the video, it is demonstrated how CoPilot can help write basic code faster, refactor existing code, explain unfamiliar code, and even generate tests for projects.

๐Ÿ’กLarge Language Models (LLMs)

Large Language Models (LLMs) are AI systems that are trained on vast amounts of data to understand and generate human-like text. They are the underlying technology that powers GitHub CoPilot's ability to suggest code completions. The video explains that these models predict what comes next based on the prompt or sequence of code provided by the developer.

๐Ÿ’กCode Completion

Code completion is a feature in many integrated development environments (IDEs) that suggests possible completions for the code a developer is currently writing. GitHub CoPilot takes this a step further by using AI to provide context-aware suggestions, making it more powerful than traditional code completion tools.

๐Ÿ’กContext

In the context of GitHub CoPilot, context refers to the information that the AI uses to make accurate predictions about what code should come next. This includes the current line of code, the open files, and any comments or variable names that provide insight into the developer's intentions. The video emphasizes the importance of providing good context to get the most out of CoPilot.

๐Ÿ’กIDE (Integrated Development Environment)

An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities for developers to code, debug, and maintain software projects. In the video, it is mentioned that GitHub CoPilot integrates with IDEs like Visual Studio Code and Visual Studio, enhancing their functionality with AI-driven code suggestions.

๐Ÿ’กToken Limit

The token limit in the context of GitHub CoPilot refers to the maximum number of characters (or tokens) that the AI can process at one time. This limit affects how much context CoPilot can consider when making predictions. The video script discusses how generating a large amount of text, such as 100 lines of Lorem Ipsum, is not efficient due to the token limit.

๐Ÿ’กRefactoring

Refactoring is the process of restructuring existing computer code without changing its external behavior. In the video, GitHub CoPilot is shown to assist with refactoring by making suggestions for code improvements, such as converting function names to camel case, which adheres to common coding standards.

๐Ÿ’กDebugging

Debugging is the process of identifying and removing bugs or errors from a computer program. The video demonstrates how GitHub CoPilot can aid in debugging by explaining exceptions that occur during the execution of a program, guiding developers towards a solution.

๐Ÿ’กTesting

In software development, testing involves the verification and validation of programs to ensure they meet the requirements and function as intended. GitHub CoPilot can assist with testing by generating test cases for code, as shown in the video where it creates a test file for a demo project.

๐Ÿ’กCode Standards

Code standards are a set of rules and guidelines for programming that help maintain consistency and readability in the codebase. The video discusses how GitHub CoPilot can adapt its suggestions to conform to the coding standards of a project, such as using camel case for function names, based on the context provided by the open files.

๐Ÿ’กPull Requests

A pull request is a feature in version control systems that allows developers to propose changes to a project's codebase. The video mentions that GitHub CoPilot will soon assist with pull requests, potentially automating parts of the review and integration process to improve efficiency.

Highlights

Todd England, a member of the Microsoft Cloud Advocacy team, provides tips and tricks for maximizing the use of GitHub CoPilot.

GitHub CoPilot functions as an AI pair programmer, assisting in code writing and discovery of new workflow efficiencies.

Large language models are the foundation of GitHub CoPilot, predicting code completions based on pre-existing code patterns.

GitHub CoPilot's suggestions are influenced by the training data it was exposed to, which may limit its effectiveness for less common languages.

CoPilot does not compile code or verify its correctness, requiring developers to validate the code's functionality.

To provide better suggestions, GitHub CoPilot needs proper context, which includes open files, top-level comments, and meaningful names.

GitHub CoPilot can help write basic code faster and is particularly useful for extending and refactoring existing code.

The tool can explain unfamiliar code and assist in adding tests to projects, potentially improving test coverage.

GitHub CoPilot can be integrated into various IDEs, including Visual Studio Code and Visual Studio, enhancing the development experience.

Descriptive variable and function names can guide CoPilot to provide more accurate code completions.

CoPilot can generate documentation for code, aiding in maintaining a well-documented codebase.

GitHub CoPilot can assist in creating tests for code, even suggesting the setup of a testing framework.

The tool can help understand and resolve errors, keeping developers within the flow of their work.

GitHub CoPilot's chat feature provides a way to ask questions and receive coding-related answers directly within the IDE.

CoPilot can help with CSS styling, including creating complex gradients and transitions, even for developers who are not experts in CSS.

The tool can refactor code to adhere to specific coding standards, such as converting function names to camel case.

GitHub CoPilot can be used to understand exceptions during the debugging process, providing insights into errors and how to fix them.

Upcoming features for GitHub CoPilot include enhancements to pull request management and additional capabilities to improve developer productivity.

CoPilot Adventures is a new initiative designed to provide developers with a fun way to try new coding challenges and puzzles using GitHub CoPilot.

GitHub CoPilot is positioned as a tool to assist developers, not replace them, aiming to make developers more effective and efficient in their work.