Post

668

I’m a bad programmer.

I have written similar sentiments here before, and I likely followed up those comments with the same explanation that I will add here. Like I said, I’m a bad programmer, but that doesn’t mean I don’t program. I have written a fair number of computer programs in several different languages. I have written programs that convert data from one format to another. I have written library software for a large company. I have written enemy ai code for small games. And the list goes on and on. All of these programs worked. Most of them were bad. Badly optimized, badly structured, and badly maintained.

I think that last point might be the worst one.

In the recent past, I have been creating a lot of shaders. Shader programming has very specific requirements, and it’s own semi-specific language designed around manipulating triangles and pixels. Mostly pixels. I’m about as good at shader programming as I am at C# or python, which is not very. But I have been manipulating pixels for a long time, so I have a pretty good intuition about what is and is not possible in that space. I know roughly what effect any particular math operation might have on a pixel or set of pixels.

I can make a good shader. Still, I’m not great at programming them. My code is messy and probably not as efficient as it needs to be.

I have found LLMs like copilot or chatGPT invaluable for this. But there is a catch. I have tried to describe the result that I am looking for from a shader and found that none of these LLMs come anywhere close to creating a usable shader. It’s always borked in some new and exciting way. On the other hand, I am very good at writing code that works but is otherwise awful. The LLMs seem to be pretty good at cleaning that sort of thing up. Organizing and documenting. Pointing out small changes that enhance efficiency. When you are running a program every frame on every pixel, those efficiencies add up.

A bit ago, I adapted a fairly complex texture bombing shader that came on one of the old Nvidia GPU gems books. I could get it running in godot, and even managed to make it run fairly fast. I used an LLM, and it cleaned and organized. My framerate went from a few hundred (already respectable) to thousands. It made a few small tweaks that I may have gotten around to at some point, but I didn’t have to. The best part is that it made my code more readable. When I went back to the shader weeks later, it was so much easier to parse.

I haven’t really tried to use LLMs to create anything from scratch, because they do seem fairly bad at that, but I think I will continue to code badly and use them as an assistant to clean things up for me.

I won’t be using them to create art - ever - so don’t ask.

This post is licensed under CC BY 4.0 by the author.