Adventures coding with AI

benwiggy

Ars Scholae Palatinae
899
I've recently been using ChatGPT's "Code Copilot" to produce Swift scripts, and it's worked rather well.

I started off by just asking for a simple function, largely as a means to get a working example of some of Apple's APIs; but by gradually building it up, in the manner of a teacher ("Now let's add this to what we've already done"), I was able to create a really useful command-line utility, without a single line of my own code.

The generated code was always not without error, but feeding the error messages back, it was always able to work out what was wrong and what needed to be changed. You do have to check that its logic is what you wanted -- there was one point where a completion handler was always returning true, no matter the result. (But just saying: "it's reporting success here when it shouldn't", it was able to fix it correctly.)

All in all, I found the experience really enjoyable, instructing my virtual apprentice to produce work for me to inspect. Certainly much more enjoyable, less frustrating -- and faster -- than trawling through Apple's documentation and trying to knock something up myself.

Of course, this is exactly where AI ought to excel -- a large amount of data, easily absorbed, with logical rules to its application. I've also given it some code that I've written, which it improved and corrected. I'm looking forward to the planned addition of AI features to Xcode.

There's another thread somewhere asking what the perfect programming language would be. For me, it would be "Computer, run a simulation to improve warp core efficiency."
 
Last edited: