AI Coding Companions: My Experiences in 2023
Published: 2023-09-26 06:22:28

One moment, it's like having your thoughts magically transcribed into code right before your eyes. The next, it's like a monkey with a typewriter belting out the whimsical rhymes of Dr. Seuss. Welcome to the wild and surprising world of AI Coding Companion tools!

Over the last year, I've been using [Amazon CodeWhisperer](https://aws.amazon.com/codewhisperer/), [GitHub Copilot](https://github.com/features/copilot), and [ChatGPT](https://chat.openai.com/) in various ways to make my hacky coding easier and more effective. With that, I've condensed my experiences into some key reflections that have definitely made my life easier.

## ✅ Writing Boilerplate Code

One of the things AI solutions excel at can best be described as "making the boring stuff go faster". We're already familiar with this, but instead of going through the vendor docs or Stack Overflow, we can skip a few steps.

This is great for things like API calls (like writing out an [S3 Object Upload](https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html) call), writing out some logic flows, and a lot of the proforma that isn't necessarily challenging, but just takes time.

![Python code written in visual studio showing a PutItem call being made to S3 suggested by CodeWhisperer in Autocomplete](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k675hz9mf3htlrdw0u96.jpg)

These suggestions can include errors which may not be immediately obvious. That isn't much of a problem when you're familiar with the topic, but when you're not...

## ❌ Handling Unfamiliar Concepts

Nobody is an expert at everything, but when writing code, you should definitely have some understanding of what you're trying to accomplish. AI tools let us shortcut this a bit, but it also magnifies the problems.

Recently I needed to build something with Python and [FFmpeg](https://ffmpeg.org/). And while FFmpeg is amazingly powerful, it can also be incredibly complicated.

![Attempt at using CodeWhisperer to generate an action with FFmpeg](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/im8b9xtil2fxzrq7tutz.jpg)

Trying to troubleshoot these errors was next-to impossible without knowing more about how FFmpeg actually worked, so I ended up going back and writing everything by hand. That said, even this process can be made easier.

## 🧠 Troubleshooting Code Issues

Writing code can be hard, and especially when dealing with new languages, you can just get things wrong. And surprisingly, one of the best tools to help with this has been ChatGPT.

Because of the extensive capabilities of the GPT4 model and the gargantuan corpus that powers it, ChatGPT is actually able to help pinpoint why some chunks of code didn't work as expected. Case in point, it was very helpful when I was trying to get some Flutter/Dart code working in an experience I posted about on [LinkedIn](https://www.linkedin.com/posts/ssennettau_okay-so-today-i-actually-used-chatgpt-to-activity-7072452548925743104-Hk_w).

![Screenshot of a ChatGPT session asking why some code was not working, a snippet of some Dart code, and the insightful response returned by ChatGPT](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tseor15xjvgfojgw15fm.jpg)

Uploading a code snippet for a personal side project to ChatGPT isn't much of an issue, but it does speak to a lot of concerns that people have around one very major relevant topic...

## 🔐 Security Implications

Uploading highly sensitive code into an unknown API that is given full access to your hard work is unnerving, and does come with risks. Especially in the corporate context.

[Amazon CodeWhisperer](https://docs.aws.amazon.com/codewhisperer/latest/userguide/sharing-data.html), [GitHub Copilot](https://docs.github.com/en/enterprise-cloud@latest/copilot/overview-of-github-copilot/about-github-copilot-for-individuals#about-privacy-for-github-copilot-for-individuals), and [ChatGPT](https://openai.com/blog/new-ways-to-manage-your-data-in-chatgpt) can all be configured to prevent it from learning from your inputs (check the links for more info). And while you’re probably already trusting these organizations with storing your data anyway (especially AWS and GitHub/Microsoft), but the risks of it being given to other customers is where the danger lies.

![Checkbox in the Amazon CodeWhisperer settings in Visual Studio Code that prevents it from learning from your code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tpswr6r1y2g9g80fqkxg.jpg)

Whether your organization deems the use of AI coding tools acceptable depends on a lot of factors (legislative, compliance, regulatory, etc.), but if there's PII or commercially sensitive information, I'd err on the side of caution.

## 🖊 Documenting Code

This was a surprising little gimmick. While we can use comments as placeholders for natural language to prompt the tool to generate code, we can also do the same in reverse too.

By starting a comment above a block of text, you can prompt the model to write a description of what the function is doing within the context of the file.

![Example showing how an autocomplete suggestion can document a function with a comment based on existing code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08u091036759cv8eigf9.jpg)

This... is actually pretty cool. It's not infallible, and so far they can only read within the context of the current file. But I could see this being useful in navigating an unfamiliar codebase.

## 😒 Fighting the UI

Integration with the IDE makes using some of these tools incredibly easy, but not always for the better. The autocomplete suggestions can be remarkably quick while writing code. Sometimes too quick.

Coding often requires a focused, uninterrupted thought process, and interruptions by autocomplete suggestions can disrupt that. Likewise, occasionally the multi-line suggestions will cause unexpected behaviour when navigating or manipulating the code you've already written.

![Simpsons meme of Lenny stating "I'm always interrupting people" with the Amazon CodeWhisperer logo superimposed over his face](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fy8maqaog3kqjsgqxi55.jpg)

These tools are great, but often it can be useful just to hit the *Pause* button for a while. Though I hope future updates can make these experiences more seamless.

## Conclusion

Generative AI supported development is here to stay. It's an inescapable fact, and will continue to change the nature of the industry. It's not perfect, and can create its own headaches, but it's also very much worth exploring.

If you're tried some of these tools, share your thoughts in the comments! If not, I encourage you to give them a try.