2 First steps with AI-assisted coding

 

This chapter covers

  • The fundamentals of GitHub Copilot
  • Creating a Python environment for a Python project
  • Building a project using generated code
  • Using code completion to generate snippets
  • Using the Copilot Chat interface

Getting started with generative AI tools can be daunting. Many people frequently ask me, “How do I get started? Which model do I choose?” Fortunately, the easiest way to start is to pick a tool and experiment. Once you do, you’ll find the learning curve surprisingly small.

We begin by using GitHub Copilot. To learn the basics, we’ll jump in headfirst to solve a programming problem. Next, we’ll build a useful application in Python with assistance from Copilot. By the end of this chapter, you’ll be comfortable using Copilot when writing code.

2.1 What is GitHub Copilot?

Do you remember the “rubber duck” debugging method? You visualize a rubber duck on your desk and explain the problem to it. You can use a real rubber duck or, like me, a toy wizard. I’ve confided in that wizard many times, working through problems. The key is to verbalize the matter to an imaginary helper. Once you articulate the problem clearly, by shifting focus, you might find solutions you didn’t see before.

2.1.1 How GitHub Copilot works

2.1.2 Interacting with GitHub Copilot

2.2 Common patterns

2.3 Context is everything

2.4 What is NLP?

2.5 A simple Python project

2.5.1 Preparing your development environment

2.5.2 Creating the application

2.5.3 Side quest: Testing the function speed

Summary