AI Schooled Me – Or How I Re-learned To KISS

Taylor Built Solutions Logo

Recently I started my journey on learning to use AI for writing and programming. My first post was about the tools I chose to use and getting them setup on my computer. The next post I planned to write is about using coding specific LLMs to help write a tool to use the CloudFlare API to update DNS records using modern C++, a JSON library, and a library to make web calls. Instead I’m writing this post about how I’ve forgotten and re-learned the KISS principle over my career.

Goals For The DNS Updater Project

I have been somewhat stuck in the versions of C++ and libraries I have been able to use in my day jobs by necessity of their businesses. C++ has become a much safer language since the C++11 standard but I haven’t been able to make much use of these modern features due to the C++ toolsets in use at work. Additionally I haven’t been able to do much programming that touches the internet and, given my knowledge of C++ and the possible performance it can bring to projects, I’ve wanted to see how C++ running on a server can handle communications. These are areas I’ve wanted to learn about but was lacking a project to do so.

When I started hosting some servers at home I found the need to update DNS records for my domains whenever my internet provider changed my external IP. This provided a project for me to do some of the above learning. Yes, I’m aware that this is a very simple thing to update and that I could automate this with bash, curl, and cron relatively easily. But it’s an opportunity to learn something. Or so I thought.

What Happened With This Project?

A year or so ago I started the process of spinning up a CMake and C++ project (because CMake is another thing I needed practice at). I began implementing a class to handle domains to update via reading in a JSON configuration file using the JSON for Modern C++ library by Niels Lohmann, logic to get the current external IP address of the computer the program is running on, a class that would handle communications via the CloudFlare API and libcpr, and the logic to call everything. I was developing everything as I would a large project at work and I was LEARNING! Yay!

And, after a while, the project seemed to becoming ever more complicated and I stopped finding the time and energy to work on it. My family will always be my first priority and we had things going on. The further away from the project I got the less impending the need seemed to be and the less time I spent on it. And, lo and behold, here we are a long time later looking at trying to use AI to help me get the project done.

What Did The AI/LLM Suggest As A Solution?

I prompted the AI to write a program in C++ that would read in a JSON configuration file with domain information and call the CloudFlare API with it to update the DNS records. It generated a single file that would do this in roughly 100 lines. ONE HUNDRED LINES.

This solution is way simpler than the design I came up with myself. I stared at the code it generated gobsmacked. Not because the code was astoundingly good but because it reminded me that, in my desire to learn, I had overcomplicated things and that I need to return to the “Keep It Simple, Stupid” concept. I need to just get the thing done.

Conclusion

I have not tested the code that the LLM generated yet but I will soon. I already recognize that there are things about the suggested code that should change. But this has reminded me of a guiding principle that I have claimed to cherish through my software engineering career but forgot in this case: Write code that is clear, concise, and easily understandable (or provide clear, concise comments if the code can’t be). In other words KISS.

Leave a Reply

Your email address will not be published. Required fields are marked *