Two weeks with GitHub Copilot: first impressions
I got into the GitHub Copilot technical preview. Some first impressions after two weeks: impressive, occasionally spooky, and confidently wrong just often enough to keep you awake.
At the end of June GitHub announced Copilot: an “AI pair programmer” that suggests code while you type, built on a model from OpenAI called Codex. There’s a waitlist for the technical preview, I signed up the same evening, and two weeks ago I got in. Some first impressions.
First a confession: the preview only works in VS Code. I’ve been a Vim person for over ten years, so I had to install VS Code for this. With the Vim extension, obviously. I’m not a barbarian.
What it does#
You type, and Copilot suggests the rest in grey text. Sometimes one line, sometimes an entire function. Tab to accept. The trick is that it uses the context of your file: the function names, the comments, the code above it. If you write a good comment, you often get a surprisingly decent function back.
An example from this week. I was working on a small internal tool for retention settings and typed a comment plus the function signature:
// parseRetention parses durations like "3d" or "2w", which time.ParseDuration
// doesn't support, and falls back to time.ParseDuration for the rest.
func parseRetention(s string) (time.Duration, error) {
And Copilot filled in the rest in one go:
if strings.HasSuffix(s, "d") {
n, err := strconv.Atoi(strings.TrimSuffix(s, "d"))
if err != nil {
return 0, err
}
return time.Duration(n) * 24 * time.Hour, nil
}
if strings.HasSuffix(s, "w") {
n, err := strconv.Atoi(strings.TrimSuffix(s, "w"))
if err != nil {
return 0, err
}
return time.Duration(n) * 7 * 24 * time.Hour, nil
}
return time.ParseDuration(s)
}
That compiles, it works, and it’s roughly what I would have written myself. Except: "-3d" is happily accepted as a negative retention period. For a function that decides when data gets deleted, that’s not a detail. Copilot didn’t know that, of course. It wrote the most plausible code, not the correct code for my situation.
Where it shines#
- Boilerplate. Table-driven tests in Go, struct tags, the tenth
if err != nil, mapping code between two structs. That’s where it really saves time. - APIs you rarely use. I never remember the exact format of a
tarinvocation inside a Dockerfile or the order of arguments forstrings.Replace. Copilot does. - Tests. Write one test case yourself, and it suggests the next five, often including edge cases I hadn’t thought of yet.
Where it gets tricky#
- It’s confidently wrong. The suggestions look exactly as convincing when they’re wrong as when they’re right. Twice it suggested a function from a library that doesn’t exist. It looked very plausible. It just wasn’t real.
- You read code instead of writing it. And reading code carefully is harder than writing it. The temptation to just hit Tab is big, especially at five in the afternoon.
- Where does it come from? The model was trained on public code from GitHub. Somebody already got it to produce a well-known piece of code from a famous game nearly verbatim, comments included. What does that mean for licences? I honestly don’t know, and I’m not using it on work code for the time being until our legal people have had a look.
- Secrets. If it was trained on public repos, it has also seen a lot of API keys that people accidentally committed. I haven’t seen it suggest a real key, but the thought alone makes me a bit uneasy.
So?#
I’m more impressed than I expected. It feels a bit like autocomplete on steroids, and every now and then like magic. But it doesn’t replace thinking. It’s more like a very fast junior colleague who has read a lot of code but doesn’t know your context, and never says “I’m not sure”.
I’m curious where this is going. For now it stays enabled for side projects. And Vim? Still my default for everything else. Old habits.