DRAFT

This is Bob Frankston's web site. Bob Frankston

IEEEChattingUp

DOI:  10.1109/MCE.2023.3299374

Preface

I need to start with a caveat – the whole field of LLM (Large Language Models) is changing rapidly so it’s likely that whatever I say here will be woefully obsolete soon.

In keeping with the theme of this column I started by asking ChatGPT for advice on how to use it for programming. I got a full version and a concise version. You can find them here (https://rmf.vc/IEEEChat1). It wrote a version that is a fine answer for a school paper without depth.

One of the big values in using LLMs for writing programs is that you get to see the hard edges and the limitations unlike prose where you can read meaning into it. If a program fails, as when Chat hallucinates an interface, you can see it. It’s a useful reality check.

Using LLMs

Like any other tool you do need to learn to use it effectively. When I wrote “About Software1” in 2016 I ended with the comment that in the future we’d just throw the problem against the wall and see what happens. I was thinking of neural nets to analyze data. The reality is quite different with LLMs.

Today I typically ask ChatGPT to take the first crack at writing a program. One of the big advantages is that it has digested many millions of samples of code and it finds all sorts of interfaces I wouldn’t think to look for or know how to find.

A good example was when I wanted to determine if two files were the same despite having different names and paths. My first thought was to use the file index only to discover that two files may have the same index if they are on different disc drives so how do I get the unique serial number? I did ask for advice from Microsoft old timers and eventually figured out I could write a C# function to get the drive serial number. But then I asked ChatGPT, and it quickly gave me the right solution. I hadn’t realized that NodeJS already returned the drive identifier in the stat structure as well as the index.

What made this especially interesting is that I didn’t know how to form the question because half the challenge is finding the right words for the file serial number.

This is the version of the code it produced. Not exactly what I would have written but it works just fine even though the file compare is unnecessary. When asked, it pointed me to the documentation.

Alas, it also hallucinates APIs, probably because some programmer left a stub or used a private library. I have to vet the code myself. It means I still need the expertise to identify such problems.

I now start coding by asking it to write snippets of code that I could quickly inspect, and use. It has changed the way I program. This approach is very useful for CSS which can be quite arcane. I can give it a general description of what I want to achieve, and it produces good CSS. I can also negotiate with it to make changes and quickly iterate.

One other major feature is the ability to refactor. I much prefer async notation in TypeScript and it generally uses “.then” notation. I can just ask it to change the code. I can even give it code that already exists and have it refactor it according to my requests and suggestions.

Creating a Site

I am shifting from writing GUI desktop apps to writing for the browser with a NodeJS backend for the desktop application. I could use Electron for this purpose but using a standard browser is more flexible and I can still wrap the viewer to make it look like an app while also benefiting from the option of providing remote access.

I used ChatGPT to write a photo viewing application. I started by describing what I wanted in the front end and the back end. My basic design used WebSockets to make requests, and, on the client, it displayed the results in a grid.

I spent a frustrating two or so days on the initial project. I say frustrating because until I reached a point where the whole system worked the way I wanted I had to negotiate with Chat about the whole project rather than parts out of context because of the interdependence of the elements.

The good news is that it quickly followed my instructions, but it also would fibrillate in doing the right thing and then forgetting what I asked it to do, it would revert to the old version. For example, I would ask it to display an image within a div and, after I ask it to size to fit, it would put the image on top of other images.

My sense is that it doesn’t have a theory of what is in my mind so it wouldn’t track my overall design. This lack of a holistic approach is a serious impediment and I expect that to change. It isn’t necessary to have a full theory of the mind but simply a better way to maintain a context in addition to the vast store of knowledge it already has.

Notice that I am using anthropomorphic terminology. This doesn’t mean I think it is sentient but it’s the only language we have or dynamic systems. And it is also useful to talk to it as if it is. That is a deep topic in its own right.

During the period in which I was working on the project as a whole I would have to again try to explain what I wanted. This went on for a while and then backslid.

Eventually I gave up having it work on the app as a whole and I asked it to write specific functions. I could also give it the code I’d modified and have it refactor it.

Even when it wasn’t perfect, I could work with it to tweak the code to be what I wanted. I asked it to write a function to grab video thumbnails using FFMPEG2 (a very useful library I’ve written about in the past) but I had to tweak the parameters to get it to work correctly.

Sometimes it just gets totally confused as when it insisted that “index.ts” (server) was really “app.ts” (client). That’s one reason I switched from whole-app changes to asking for suggestions for functions and HTML/CSS techniques.

It’s easier to ask how to do rounded corners for a div than looking up border-radius. It’s better than me for pawing through documentation.

I next used Chat to upgrade my main home site to add authentication and gave me a very simple and useful approach so it’s now safe for me to openly show the URL. I then added my own improvement so it doesn’t ask for authentication if you’re on my LAN (as if I let you in my house) so that I can use webapp for home control within the house and then authorize my family members to use it remotely.

Programming is now about negotiating rather than just dictating code. I can now explore ideas that seemed like too much trouble. After I gave up, Chat found APIs for me that allow me to dynamically choose the correct authentication certificate dynamically and share a port for both https and http. I had tried to figure out the APIs myself, but it was too frustrating. Chat ferreted out the APIs quite quickly.

Changing the Nature of Programming

When I wrote “About Software” I commented that Fortran was supposed to eliminate the need for programmers by allowing mathematicians to just write out formulas [FORmula TRANslation]. It turned out that it really didn’t eliminate programming. Since then, we’ve continued to refine tools to translate intent into precise code.

Chat is dramatically different. I have a brilliant but not necessarily wise assistant. I need to understand the code it produces so I can take responsibility for the result.

I now program by starting with Chat and then refining it.

For consumer electronics companies building devices it could reduce the difficulty of building well-specified components and allow for more emphasis on the user experience by rapidly iterating the design of the whole system. But that’s a topic for a future column.

Caveat

I repeat my caveat that all this is changing rapidly and is likely to be very different by the time you read this. Have fun with your new tools – imagine the new possibilities.


End Notes

Click on the note number to return to the text.

1 https://rmf.vc/IEEEAboutSoftware

2 https://rmf.vc/IEEEHiFiToCLI