Pair programming with AI
I recently completed a LinkedIn Learning course, Pair Programming with AI, by Morten Rand-Hendriksen. Morten demonstrates a number of strategies for using AI as a pair programmer and utilizes ChatGPT, GitHub Copilot, and Bing Chat. I recommend completing the exercises. In addition, I share below some notes.
How does AI know how to read and write code?
- Simple way to think about it: code is just language and large language models like ChatGPT are designed to create sentences emulating language based on its training data. The longer answer is that AI companies have trained large language models using examples of coding languages and as a result, these AI systems are able to generate sentences emulating those coding languages.
- There's no actual intelligence, no conscious thinking agents inside these systems sitting there writing the code. What's really happening is generative AI interprets your prompts and responses by putting together sentences word for word based on statistically guessing at what the next word in the sentence should be. And since coding languages are far more structured and patterned and logical and model based than are regular human languages, the chances of the AI successfully putting together functional code is quite high.
- Because these AIs are not actually writing or testing code, but instead putting together sentences that look like code, in many cases, they're just repeating the existing coding patterns found in their training data. As a result, AIs have a tendency towards repeating old coding patterns and standards. So if you're trying to do something new, the AI will probably not be able to help you.
Mental models for AI pair programmers
- For conversational AI like ChatGPT and Bing Chat, think of them as overconfident junior developers with deep historical knowledge and a shallow understanding of modern standards. They can reproduce common patterns, but faced with newer language features and coding practices, they fall short because they rely on their training data and that training data will always be old.
- For in-app pair programmers like GitHub Copilot, think of them as supercharged and frequently wrong autocomplete, an advanced evolution from the autocomplete on your phone that gets things right until you send an important message and then make some sort of embarrassing error.
- And for all of these tools, present and future, when they do something that amazes you, always remember, you are talking to a machine. It's just sophisticated software. Artificial, yes, intelligent, no. AI is a tool to help you do your job.