If I want to throw an exception if an object is null or undefined, Co-pilot will do the if and the exception throw using the right error class, and a more meaningful error message that what I usually came up with.
If want to map some random technical data table to something useful in my programming language, I can copy paste the data from the documentation in pdf or html into a comment block, give an example, and co-pilot will write everything in the format I want.
If I want to slightly refactor some code, I can do it once or twice and co-pilot can help me a lot to refactor the remaining.
If I want to have a quick http server in nodejs, I don't have to Google anything.
It's a lot of tiny things like this.
I'll reproduce a generic example I sent a friend.
Prompt:
const redis = require('redis');
// Create a redis client
Copilot suggested: const client = redis.createClient();
I accepted it and moved 2 lines down, prompt: // Get the current count from redis
Copilot suggested a start to the operation: client.get('count', (err, count) => {
I accepted it, and Copilot continued: if (err) {
console.log(err);
return;
}
// If there is no count, set it to 0
if (!count) {
count = 0;
}
// Increment the count
count++;
// Set the new count in redis
client.set('count', count);
// Log the new count
console.log(count);
}I will say, though, that it's also good at making up code that looks very believably real but doesn't actually work.
The ethics involved in Copilot are a bit strange, and I'm not sure I'll keep using it for those reasons, but it does a good job.
So, I actually consider this to be exactly the bad behavior that people accuse Copilot of.
// Create a redis client
Writing that probably takes a longer time than just doing it with the IDE help in jetbrains, though?Press "r", press "." to autocomplete so it now says "redis.", then write "cC" and it suggests createClient (or write "create" or "client" if you're not sure what you're looking for). Now it says "redis.createClient()". Press ctrl+alt+v to extract a variable or write ".const" and press tab to apply the const live template. Ending up with your result in two seconds.
+1 for the variable extraction thing, I've been using their IDE for ages and it never occurred to me to look for such a thing.