How (Not) To Use AI When Learning to Code
Tags: ai, beginners, learning, saas
Published: 2024-06-06 15:00:00

I remember the first time that I used ChatGPT. I was at at a friend's house for a board game night and this new, game-changing technology had just been released. We passed my phone around the room and generated a whole script for a new Batman movie! That was before ChatGPT allowed you to save conversations, so our groundbreaking new piece of cinema never saw the light of day.

We've been blown away by what AI can do over the past few years, including its ability to write code, and write it fast! I'm not a catastrophist who thinks that AI is going to take over the writing of codebases everywhere, in fact, I think that the AI movement is actually *more* of a reason to learn how to speak the language of computers in 2024. If you're learning to code right now, AI should be a tool in your toolbelt, but without care, you may become a lazy programmer.

## The Temptation

You've just had a great idea! An app that tracks art prices and alerts you to deals in your area. (Someone might want it, I don't know). You sit down for your first planning session for this application, and you realize that not only are you going to have to design a front-end that artistic people will find pleasing to look at, but you'll need to find an API to work with and integrate a dataset with your front-end, and manage location data for all of your users, and oh yeah, you need to manage all your user data…

You're overwhelmed, quickly. You're just learning to code. So you have an idea, just tell ChatGPT to do it for you! So you type a prompt in. You may have to ask it multiple times over, but it will eventually generate all the code you need to eventually construct your application. Great! You're done, but what did you learn?

## The Problem

Your app might work, but there is a huge problem with building something this way. Namely, you don’t understand it! If your goal is to actually learn how to work with modern programming technologies, you have to work with it, and struggle with it, and break through the wall of error messages to a deeper understanding of how these things work.

Maybe you're saying, "I don't really care if I learned it, it works!" That may be true, but can you really put that into production with confidence? It works, yes, but it only works *for now*, or *in these defined cases*. And as soon as something breaks, you don't know *why* it works, or what went wrong, or importantly, how you can fix it! What about when there is a security vulnerability that is discovered by a malicious actor? It would be dangerous and irresponsible to collect and store user information in a system that you cannot secure or fix.

"But, it's AI! The collective knowledge of the internet has created this!” Ah, yes. The old "if it's on the Internet, it must be true." Here's the issue, Artificial Intelligence emulates some of the greatest feats of the human brain: the ability to connect disparate information, the ability to be creative (arguably), the ability to analyze data. But, it also inherits the ability to be incorrect, to make assumptions that might be baseless, to draw conclusions from data that seem obvious but on closer inspection are inaccurate. I, myself, have prompted ChatGPT to write a function for me that comes out the other side completely unusable.

AI will continue to improve, and the code that it produces will become more and more accurate these models continue to be trained. I have no doubt that the prompts that we give machines will get us closer and closer to the results that we’re looking for. But, the need for programming is never going to leave us completely. Programming is not just writing code, it is the ability to solve difficult problems. There will always be a market for that, and AI is another of the tools that will be used *by* programmers to solve those problems.

## So, I Can't Use AI When I Code?

If your goal is to learn and gain understanding, having ChatGPT write your code is not going to bring you closer to that goal, but that doesn't mean that there's not useful ways to integrate it and other AI into your learning. Here are a couple ways that I've found it beneficial.

### 1. Linting

You know what's not necessarily making me a better programmer? Finding that extra semi-colon or counting the number of brackets that need to be at the end of my function to properly close it out. (However, learning to structure your code for readability is a good skill to develop). Linters built into text editors are typically good at finding the issues and fixing them for you or notifying you before they cause errors, but have you ever just had all of your code underlined in red and you can't find out why? This is a great time to copy it and ask your resident chatbot to "Act as a linter and tell me what syntax I got wrong."

### 2. Brainstorming

I've found that AI is a great tool for idea generation, even outside of coding. You have a lot of ideas that sometimes you need the right question asked for you to uncover. I regularly use AI as a journaling prompt system to get me thinking about my goals, and problems that I have to help me work around a solution. We can use this in the beginning stages of a feature to find edge cases to plan for, and to intentionally bend ourselves outside of what we might normally think.

Use prompts like,

"Ask me a set of questions to help me identify the most useful features to implement and a target audience."

"Guide me through a brainstorming session, give me helpful questions to answer."

"I am thinking of solving [X] problem with [Y], is there anything that I'm missing?"

The key here is that you're still doing the work! This would be the same as getting in the room with someone else and getting input on some ideas, or bouncing your ideas off of another person! If you tried to do partner programming and expected your partner to do all the work, you wouldn't have a partner for long (and you wouldn't be learning anything)!

### 3. Documentation

While you're coding out a web page, or a new feature implementation, you're going to forget what arguments are taken by a method, or whether you were supposed to use brackets or curly braces. Programmers have been going to documentation for these questions since programming has existed (and then later to Stack Overflow). But, AI, as a data analysis tool, is very powerful for these types of questions. Looking up boilerplate doesn't make you a better or worse programmer, it's a task that you will inevitably have to do and AI can save you plenty of time in this regard! Be careful, because you can ask it to do more for you than just generate the boilerplate! But, there's no harm in using reference material for learning and AI can be a great reference tool!

Use prompts like,

"Please provide for me the redux boilerplate for configureStore."

"What are the built-in methods for the Math object?"

"What is the default file path for my nginx config file?"

## Conclusion

AI is a game-changer, but it can also be a short-cut to programming that will cause you to lack understanding of your own codebases and projects. AI is a tool that will speed up the completion of many different tasks, but, it is not a replacement for our own problem-solving ability. The phrase that is floating around the internet rings true: AI will not replace you, the worker using AI will. So, be a programmer who uses AI to learn to code, but don't skip over the learning process using AI. Learning is difficult. If it isn't, then you're probably not learning anything. As with many new technologies, AI will be a tool used by many, the goal then is to learn to use it effectively.