Thursday, May 25, 2023

Coding With AIs Prompts Are Important

Last night, when I could not sleep, I got up and wrote some code. I added some features and data checking to my Wordle solver helper program. When I finished I felt good about my work and myself. I think that made it easier to get to sleep and I slept well.

It got me thinking this morning. When I was in university and still learning how to code I would occasionally get frustrated and feel less confident. So I would write some simple program to help me feel like I could actually code. I must have written code to display the multiplication table from 1 times 1 to 12 times 12 at least once a semester. It worked for me.

Now that is a trivial program but it involves nested loops (for me anyway) and I am not sure I would assign it to students today. It’s really a meaningless program in today’s world when everyone has a calculator app on the phone they don’t leave the house without.

I did wonder how an AI would write the code. So I opened the chat option in Bing and asked it “Write some C# code to display multiplication tables in a list box” It gave me some code that displayed this:

Not what I wanted at all. The problem is ambiguity! So I tried again with “Write some C# code to display the multiplication table from 1 times one to 12 times 12” and got this:

Not what I wanted either. So I specified at grid format “Write some C# code to display the multiplication table from 1 times one to 12 times 12 in a grid format”

This reply required a dataGridView object and the program did not work. Looks like I need to set up the dataGridView object in ways the AI did not explain. Now there is a problem worth thinking about. I asked Bing what settings I needed for the dataGridView and it gave me several. Program still did not work. At this point I gave up on the dataGridView option. It sort of feels like overkill anyway.

So I tried another prompt “Write some C# code to display the multiplication table from 1 times one to 12 times 12 in a grid format in a list box”

Finally I got what I wanted even though I am not thrilled with the formatting.

I’ve got a number of takeaways from this. Yes, students could use  these AI tools to get code for typical school assignments. On the  other hand, I think it would be fairly easy to tell when they do. The use of features that are not typically covered in class lectures or demos would be one clue.

It’s not always easy to provide the right prompts to the AI. Sometimes it takes some iteration. I think though, that teacher have to reduce ambiguity in assignment descriptions in many cases. Arguably some amount of ambiguity is helpful to allow for creativity. It can be a fine line,

As noted, I didn’t like to formatting so I did modify the code to get closer to what I wanted. I think programmers are going to be needed in a lot of cases to finish off what AIs generate. Both providing the right prompt and finishing off will be important skills for some time to come. Finishing off is going to require some serious skills in many cases BTW. Programming is not dead yet.

No comments: