:: krowemoh

Saturday | 28 DEC 2024
Posts Links Other About Now

previous
next

Testing out Copilot - 02

2024-12-21
ai, copilot

It's been a few days now since I set up copilot. I think I'm getting a better feel for it now and starting to see where copilot may be useful.

I originally wanted to use it to generate entire programs. I had this idea that I could write a comment and it would generate a function but this doesn't seem to work that well. I have seen videos of people using AI tooling this way but I haven't been able to get it to work.

What works better though is treating copilot like an autocomplete engine. I start typing part of what I want and then let copilot give me a suggestion. I can then tab to accept it or continue typing and give it more context. I would like to be able to cycle suggestions but I'm not sure if this will be that useful.

Once I tab complete, I then spend a moment to read the code that it generated and make sure that it makes sense. I can see this being a bit dangerous as eventually I'll just start accepting the code. Snippets are constant, AI suggestions are not and so I can't fully trust them.

I like the fact that now that I have copilot, the suggestions are baked into the editor and that it is aware of my coding style and the file its working on. This means that when it generates code, it generates it the way I would write.

The drawback here is that if I wrote crappy code, it's going to give me crappy code. There would have to be another step where it suggests better code maybe. I would like it if I was writing and it told me, "hey, using this variable name is not that great, use this". I'm not sure how it would play out but I would like it if copilot made my codebase better rather than more of the same. Though more of the same is fine as it is still helpful.

Example

I am writing a crud and had to write the delete function. Copilot basically autocompleted most of the logic. It also followed the exact same logic from my update logic and so it was easy to verify. If I had wrote it from scratch, I would have taken an extra few minutes to figure out which part of the update function I need to copy to create the delete.

This wasn't a huge thing but it was really nice to be able to generate the code and then just check it.

Misconception

I had believed that reading the code was going to be painful but if Copilot generates code that is plausabily something I wrote, the reading code part becomes a lot less painful.

It is reading other people's code that is hard because you don't have their context.

That said, I do think copilot is going to result in a lot of boilerplate being autogenerated but it's also going to force me to read more code than I write.

Experiences

So far I've only been happy with copilot in the context of javascript. I'm using it while doing a svelte project and I can quickly tell if something is right or I need to reject a suggestion. It's not even a consious decision, I'm able to continue typing while reading the js code it suggested.

I don't have this abiliy for rust. This means that I can't tell if a copilot suggestion is actually going to work or not just by reading. This means that if I accept a rust suggestion and it then results in a compiler error, I'm stuck. I don't know why the code generated that way and I don't know why it's breaking. The rust compiler is great as it tells you where the error is but that doesn't help in figuring out why it's happening.

Copilot in my rust project is more of nuisance than help and I'm debating turning it off in rust files. I need to learn and use rust more before Copilot is going to be useful.

Based on my experiences, I can see that copilot anaylzes the current file to give me suggestions and so I hoped to use it on a lanaguage that it is unaware of. I tried to make changes to a large BASIC program and it gave me utter garbage. It wasn't able to act as even a snippet engine. I had hoped it might be able to at least copy and paste chunks from other parts of the file but it wasn't.

This is probably trying to do too much and I just need to hope that the BASIC code in the world grows enough to a point where an AI model trained in the future can write pick BASIC. I definitely think it's coming, whether I want it or not so might as well get on board.

Thoughts

I think it was a good idea to try and use Copilot especially as I've only used chatgpt through the chat interface and used llama3 programmatically. Using Copilot directly in vim is fantastic and it gives the AI stuff a better shot.

I'm still not seeing why all the other programmers are raving about it but I'm happy to continue testing.