Using AI to Relearn How to Program: Part 1
Last August 2024, I was chatting with a friend over coffee. Our conversation turned toward some startup ideas we had. During our discussion about how we might try to prove some of these ideas, I had an inspiration: What if I could use AI to help me relearn how to program?
You see, I worked as a software engineer during the early part of my career. I was a member of the technical staff at Sun Microsystems, and I wrote code in C and C++. I used Motif, X11, RPC libraries (and eventually HTML and Java). But as my career progressed, I became more of a leader and manager. Over time, I was coding less since I was leading and driving all the work needed to release a successful product. I became a manager, helping people, teams, and groups strategize, plan, and execute. I facilitated and mentored many. Over time, my hands-on programming faded, but I never lost my technical chops. I could still lead and follow technical discussions and question risks in software development from my team.
I hadn’t kept up with modern programming languages and frameworks, so I decided to experiment: What if I used AI to guide me in relearning how to program with the modern languages used today? I needed a new trivia game for our SF BABAM Meetup. In thinking of ways to change our icebreaker trivia game, I was inspired by an old American game show, the $20,000 Pyramid. What if I blended that game with trivia? And what if I used that inspiration to relearn how to program using AI?
Starting the Journey with AI
I knew from managing engineers and reading up on AI that I wanted to build this using Django, Python, and React. To kick things off, I crafted my first prompt for AI. I described my vision of the game in plain English. I asked for guidance on bootstrapping the app with the tools that I was using: PyCharm for my IDE and a Mac for my development environment. My prompt included some context about my experience as a programmer and my need to reacquaint myself with software development. I let AI know I wasn’t a n00b programmer.
I had already been reading news articles about how AI could generate code. I was very surprised by the responses I received from AI. The instructions were detailed and enlightening. If I didn’t understand something, I could dig further and get an explanation that would help me know better (for example, the concepts behind how Django does things).
Learning from Your Mistakes
One cannot learn unless one makes mistakes and tries to understand them. That is what I initially learned about coding with AI. AI’s answers seem very authoritative, with detailed instructions and explanations. I started coding away, entering the commands and code. And quickly, I ran into problems.
The first problem I ran into involved an npm command that I needed to invoke to build my React frontend. I got an error but couldn’t figure out why. I went back to AI to ask why the command was erroring out and what possible solutions were there to solve it. AI returned an answer that I wasn’t expecting: it had given me an old version of the files to install and told me to install a newer version.
I knew that AI makes mistakes (hallucinations, anyone). It takes time for new AI training and data sets to propagate, especially when things like open source change rapidly. I’ll chalk this up as similar to a brand new experience with learning a new language: until you do something, you won’t know the quirks of specific releases. I encountered this same kind of error in the past as a programmer whenever new software APIs and versions came out. AI makes the same kind of mistake that I would as a programmer. So, I wrote down a note to myself so that I could remember and reuse the solution whenever I bootstrapped new React code.
Learning by Doing (and Debugging)
I continued to code and progress with the suggestions that AI gave me. I reached the limit of my first prompt and decided to start a new session, using an updated prompt with a JPEG as an example of the board I wanted to see. I got my code compiled and running on my dev server, but one problem would not go away – the web page that AI came up with would come up like the JPEG I gave. I made sure I was describing it correctly in my prompt. I checked if there were any error messages from Django or React (there were none). I always kept telling AI that the web didn’t look like the JPEG. It gave me various solutions. It gave me lots of code to add to debug. Nothing was working.
After poring over the code, I could see nothing was wrong with the React Javascript code. Then it dawned on me—maybe the problem wasn’t the code. Perhaps it was something else.
So, I rephrased my prompt. “I don’t think the problem is with the code. The React styling is not present at all. Am I missing a React package somewhere?”
Voila – AI gave me an answer: “The Tailwind CSS classes don’t seem to be working, which suggests that Tailwind isn’t properly installed or configured. You need to…” Tailwind never came up when I asked AI to help me set up my project and build out my UI. AI had a blind side that I encountered.
It came down to reframing the problem. If you find yourself not getting anywhere, then the problem may be elsewhere, and you have to reframe your prompt.
Upping the Ante
I decided to iterate again further. However, I upped my game this time around and used Miro to create a UX of what I wanted to see on the screen. And voila, I’m happy to say that I was able to get a web page that I liked. I learned that prompting your AI is very similar to a cross-functional Agile team – you need all viewpoints of Product, UX, and engineering so that AI can help better generate the answers you need.
Key Takeaways
So, what insights did I learn during this stage of playing with AI to relearn programming?
- AI is a Partner, Not a Replacement: While AI can accelerate learning, it’s not a substitute for foundational programming knowledge. Knowing how to debug, find the root cause, and ask precise questions is crucial.
- Iterative Problem-Solving: The process of trial and error is an integral part of programming. AI enhances this by offering suggestions, but understanding your tools and frameworks makes troubleshooting more effective.
- Context Matters: AI’s responses depend on how you frame your questions. Rephrasing or breaking down complex problems into smaller parts often yields better results.
- Use Mulitple Data Sources: While AI can accelerate learning, it’s not a substitute for foundational programming knowledge. Knowing how to debug, find the root cause, and ask precise questions is crucial.
Stay tuned for Part 2 of this continuing story. I’ll dive deeper into how Agile concepts and what coding tools are out there can accelerate your coding with AI.
I started this journey around August 2024. This blog post is a recollection of my learning journey, as captured by the history of my AI prompt usage. The journey has continued since I started playing with a few other programming projects. If you’re considering a similar path, remember: it’s not just about the code; it’s about adapting, questioning, and growing with the tools at your disposal. Feel free to ping me if you want to chat further.