Thoughts on Generative Programming in Software Engineering

ยท 817 words ยท 4 minute read

Generative AI Everything ๐Ÿ”—

Tools like ChatGPT have gotten a lot of attention lately due to some major technology companies making huge investments. They offer the ability to create content quickly using natural language processing. For example, Bing Chat can write a 100-line Java program that compiles and produces exact results given a prompt that might only be a dozen, plain-English words. I decided to try to create as much content as possible for my latest project using only Generative AI, and I have some thoughts.

The Good ๐Ÿ”—

I was able to create 80% of the HTML, Javascript, and CSS code needed for my project using Bing Chat. I asked it for very specific requirements - each section should contain x, y, z where x is static content, y is a form, and z is a dynamic list. The output was tuned to my specific request by revising my prompt when I asked for Vue bindings. Chatting and iterating with Bing Chat to get what I wanted in code took about 30 minutes, and it could have been done in 15 if I had the experience I do now. However, to author the same code would have probably taken me 8 hours.

For the backend of my application, I decided to create a go server. I wrote a spec in markdown with uri’s and some sample json responses and copy+paste’d that into Bing Chat asking for a go http server. To make my server a little more secure I asked Bing Chat to simply “add authz”, to which it created a middleware and auth function, integrating into the existing http server code. Drilling down on the authz, I asked for implementation of a bearer token and specified the claims I wanted. Again, this took about 30 mintues and would have taken me about 4 hours. The output was again probably 80% complete.

Overall, I think I could create a simple application with a frontend and backend like this in four times the time it would take me without Generative AI. It saved me a ton of time in the boilerplate and even decision-making.

The Bad ๐Ÿ”—

Bing Chat got stuck more than once. The Vue element binding was wrong in the first output and I continually got incorrect solutions when asking the AI to fix the issue. In another instance Bing Chat refused to continue helping me for no apparent reason. I had been asking it for more specific style requirements - to make list item links look more clickable - and it decided that the conversation was over.

There were also multiple occassions where Bing Chat gave me outputs that would not compile (or - in the case of Javascript - produced runtime errors). The go server code used multiple mappings to the same handler, which is not allowed, and it was able to quickly resolve that issue when I pasted the error in the chat. The token logic I asked for was also buggy because it used an outdated library that had been deprecated in 2021.

Altough there were issues, I was able to quickly resolve them through compiler outputs and iterations with Bing Chat. The worst part of the experience was how confident Bing Chat was in its outputs despite their inaccuracy.

Opportunities ๐Ÿ”—

I think every programmer, regardless of their seniority, should be using Generative AI. This is a tool that fundametally changes our craft. However, this is not a replacement for Software Engineers at any level.

It saves a lot of time in spaces where new, isolated code needs to be written. For example, a new project, package, or even function. Need a package for connecting to a specific database? Use Generative AI. Need a UI for your backend? Use Generative AI. Need a function that will decode and transform a json response? Use Generative AI. The reality is that 99% of a developer’s code has already been written by countless others on GitHub and there are already good solutions.

The programmer’s primary responsibility is now to integrate the produced solutions into their existing environment. The outputs need to be reviewed, tested, iterated on. The existing code needs to change in minute ways that are too complex and high-risk for a Generative AI to complete. Importantly, the outputs need to be carefully considered for security gaps.

Impact ๐Ÿ”—

Computer Science education needs to change to adapt to this. I’m aware that some universities are prohibiting the use of Generative AI for programming assignments. This is a terrible mistake. Engineers who are skilled with this tool will save time, produce more, and push organizations further.

We should be adapting our lesson plans to encourage or even neccessitate the use of these tools. Students should continue to learn the fundamentals of operating systems, logic, networking, and security because these will help them use Generative AI. I think the curriculum should shift away from languages and toward applications. The