There is plenty of talk at the moment surrounding a rapid increase in the power of Artificial Intelligence (AI). In particular, we have seen the image generation tools (such as OpenAI’s Dall-E) and language models (such as ChatGPT) as well as a big increase in the conversational and processing abilities of chat-bots (you know, those annoying things that sit on every website storefront).

The Learning Media Team at UNE have been exploring these new technologies and how they can assist with our work. We have found applications in multiple areas including 2D and 3D graphics texturing, video captioning, stock image generation, and computer programming. This post will focus on our team’s work with OpenAI’s ChatGPT, the AI-driven chatbot, to assist with the development of JavaScript-based learning media artefacts (think quizzes, drag and drop activities, simulations etc).

Note: It is my hope that regardless of whether you are a programmer or not, the concepts presented in this article will still make sense and offer some useful insight. Most of the code examples are simple enough that non-programmers will (hopefully!) be able to understand the concepts shown in the example videos.

Overview

Learning media development often involves writing computer code that handles interactions performed by a student. At its simplest, we might use code to determine what to do when a learner presses a button:

IF (learner presses button) THEN (start the lesson)

Working with code can often be a slow and frustrating process, involving:

  • Problem solving how a particular interaction should be written (Logic)
  • Making sense of code written by others (Interpreting)
  • Writing comments inside the code to assist other team members (Commenting)
  • Making edits to existing code (Refactoring)
  • Fixing code that is not working as expected (Debugging)
  • Simplifying code to make it as easy to maintain as possible (Optimising)

In relation to the above, our team has found that making use of AI can, in the right circumstance:

    • Greatly speed up development
    • Enhance professional development for staff
    • Assist with sustainability of code-based projects
    • Increase code quality and efficiency, and
    • Reduce cognitive load for programmers (this last one is my favourite!)

Below is a brief look at how programming techniques can be enhanced by leveraging the power of chatGPT. I have kept these particular examples simple in nature, however it is important to note that the same techniques work with larger and more complicated projects. It is worth noting also that chatGPT does a lot more than assist with programming tasks – and I would encourage anyone with an interest to spend some time chatting with the system to get a sense of its potential.

Logic

You need a holiday, but first you’re going to need to work out the logistics. Will you catch the train or drive? How can you ensure to get to the airport before the plane leaves? Better put the thinking hat on. This is what computer programmers do, except there is no holiday and we mostly sit on chairs. Hilarious jokes aside, this is a good analogy of what can often be a very time consuming aspect of development – figuring out the logical structure and flow of code so that everything functions for the end-user at the right place and time. With this in mind, it needs to be said that ChatGPT has often humbled and surprised me by creating a more elegant solution than I would have devised myself. This is great from a learning perspective and also results in a better-quality product. Elegant code is easier to read and maintain, and tends to run faster too. Below is chatGPT’s solution for “How can I calculate a person’s age, based on their date of birth?”

 

Interpreting

Writing elegant code is great and all, but the doofus programmer who quit last week has left you trying to interpret the trail of javaScript madness they have left behind. Asking chatGPT to explain code can speed up the process of making sense of code you are unfamiliar with. This is also a great learning tool for beginners, who might, for instance, know what a piece of code does but not how it works.

 

Refactoring

Programmers will generally approach a project in chunks. We get one piece of functionality working, by writing code that performs one simple task, then continue adding functionality one piece at a time. This process typically involves making lots of edits to existing code, as new features are added. ChatGPT can understand existing code and make these types of edits, adding or removing features as needed.

 

Commenting

Writing comments with code (ie. tips that explain what the code is doing) saves headaches for developers. If the aforementioned doofus programmer had taken the time to include comments we wouldn’t be giving ourselves a migraine trying to interpret what they wrote. Thankfully, ChatGPT can comment code for us, and even create documentation for project handovers. In the example below, you can see how human-readable english comments are being added. The original and resulting code do exactly the same thing, however the latter is much easier to interpret.

 

Debugging

There are many different types of errors that can occur when a program is run. Syntax errors mean our code contains typos, Runtime errors mean our code runs, but not the way we expected it to. By feeding some code to chatGPT that contained both a Syntax and a Runtime error, the system was able to identify both of them, although it did need a bit of encouragement to look a bit closer at what I was trying to achieve.

 

Optimising

I mentioned earlier that chatGPT writes elegant and efficient code, but you can also employ it to fix your own lazy horrible code. Time for another analogy. If your boss needs you to get out of their office and never come back, they might point to the door and say “take a step, now take another step, aaaaand another”, which would be rather silly since they could just as easily have pointed to the door and said “take 10 steps that way, fool!”. As a rule of thumb, if you are repeating the same code (“steps”) over and over, you’re probably lazy and it’s time for our AI overlords to fix things for you. In the below example, you can see I was using the same line of code (“console.log”) repeatedly to print each day of the week. ChatGPT was able to recognise ways in which the code could be streamlined. It even thought to fix my misspelling of the word ‘Tuesday’ and let me know, you clever chat-bot!

 

Conclusion

By using these techniques the media team has already seen projects developed in far less time, and with fewer headaches, than would previously have been expected. As AI systems are improved and the technologies continue to be integrated into our software and workflows, we expect that this early experience has certainly given us a small taste of big changes to come. Whether or not we like it, AI certainly seems like it is here to stay, and I encourage anyone with an interest to watch this space. We have lots more work with AI to share with you in some upcoming posts – including an artefact that employed AI-generated code as well as AI-generated images to assist with development – so stay tuned, human!