Using AI to convert code, is it a good idea?

~ 3 min read

I’ve been using AI assisted coding for over a year now, initially with the GitHub Copilot Beta, then AWS CodeWhisperer, both have their benefits and their downsides. Then along came ChatGPT where you can ask things like “write a Todo app in Javascript” became possible, which it did as a console app, with follow-ups of “re-write in Vue”, “re-write in React”, etc.. It was impressive. But I’ve always been aware I’m the quality control. It’s not a programmer replacement, at least for now, but it certainly shifts the programmer’s role into testing, and writing tests.

What concerned me this last week is when I needed to convert a large Vue 2 component to Vue 3 and use the composition API, the team I’m working with said just use Chart GPT, but I’m not familiar with Vue 3’s composition API, how do I know it’s done a good job? I’m the tester right? The component was also so large that Chat GPT couldn’t convert it in one copy and paste. Sure, I could have used defineComponent({…}) and avoided the pain, but I needed to understand the Vue 3 composition API, and then validate what ChatGPT had done.

So in the end, I ditched using ChartGPT completely and learnt the Vue 3 composition API, learnt that the app into which the component I was converting had a bunch of nuisances and bug fixes that would need to be done as we transition the whole frontend to Typescript also. ChatGPT would never have got sight of this.

Bottom line ChatGPT and other AI tools are amazing at increasing programmer productivity, but using them without the base knowledge to understand what they output is a major mistake, and often, it’s just quicker to write the code yourself rather than have AI write it and have to check it. In this latest respect, I like AW Codewhsiperer; it tends to make smaller code completions than GitHub Copilot, which makes generated code easier to validate thanks to the smaller cognitive load.

Most importantly, seeing how your “new code” sits in the overall code base is really vital, and right now AI does not have that visibility, I’m sure it will, but until it does, AI coding needs to be used judiciously. If you like, it’s the difference between a Junior and Senior/Lead developer; the former gets the immediate job done; the later gets the job done with respect to easing future development.

Bottom line, if you don’t know how to code something yourself, don’t ask AI to code it for you because how can you validate the output otherwise. Do use AI to speed the development cycle when you do understand the output it produces.

AI is going to revolutionise so many things, well it already has, it’s just becoming much more front and centre now, touching everyone, rather than being a behind the scenes’ technology.

all posts →