AI Coding Companions: My Experiences in 2023

AI Coding Companions: My Experiences in 2023

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, GitHub Copilot, and ChatGPT 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 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

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. And while FFmpeg is amazingly powerful, it can also be incredibly complicated.

Attempt at using CodeWhisperer to generate an action with FFmpeg

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.

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

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, GitHub Copilot, and 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

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

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

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.

Headshot
Stephen Sennett
Stephen is a cloud technology leader. He has worked in the industry for over a decade, holds high-level technical certifications, spoken at events around Australia and internationally, and recognized as an AWS Community Builder.