Github Copilot is the Coach I always Wanted

We hear a lot about the bad side of AI Code Generation etc. But there are also quite some good sides that should not be ignored.

Kickstart Configs

When I started more and more , I used GitHub Copilot and Mistral to write my docker-compose files in order to learn how they worked. Sure, I could have tried myself, read a lot of documentation – but this was just ways easier and most important: ways faster. And I also didn’t want to master the details of network configs in docker files. We’re still speaking of hobby projects in my spare time.

Refactoring / Switching APIs

I have a very simple web application that builds the ALT-Text for photos and I used Astica.ai until recently. I wanted to switch to Mistral.ai mainly to know exactly which AI company is being used and because the APIs are just super simple nowadays so that I do not NEED an additional service in between.

I (more or less) just wrote: “please refactor the code to replace the astica.ai-API with the Mistral.ai-API without changing the UI”. And it worked! A code review later and I was done. Again, I could have tried myself – but getting into the API specifics of Mistral really isn’t what I want to do in my spare time. Unlikely that I would need that very specific know-how very soon again.

Refactoring for better code

I also refactored another very simple Web application with a bit of python backend. After the refactoring was done, I advised Copilot to do a code analysis: Are the functions too long, too complex? Should I split the file into multiple files? And asked for an analysis and suggestions.

And I got a great analysis with suggestions. I thought about the suggestions, clarified some details, and finally accepted some of them and discarded others. But it also missed some things that I saw in the manual code review. Nothing crucial, but still.

Without the copilot … I would simply have missed a sparring partner. Keep in mind: This is not a work project where I can ask a colleague who has a good feeling for “good code”. It would just have been a discussion with me myself. And of course, I can’t improve code where I do not know that better ways exist, like some list comprehensions that I wasn’t aware of before.

Decades ago, I remember how often I refactored my own hobby projects, ending up in a different state of code … And not necessarily better to be honest. Yes, it was all fun, but nowadays my time is ways more limited, and I am happy to have a sparring partner with an additional opinion.

Is it all Good?

AI code assistants are – a without doubt – a double edges sword. But they also offer a really good opportunity to learn and improve.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *