Can ChatGPT Teach Me How to Code?
Artificial intelligence is becoming more and more popular nowadays, and a lot of people have the question, "Can ChatGPT teach me how to code?"
I have already heard many success stories about how developers are using ChatGPT to work more efficiently, treating it like a colleague or a developer who can help them solve their problems. Yes, it is entirely possible, but I think that ChatGPT is not suitable for all developers.
It is more suitable for advanced developers than for beginners.
Why is that? Advanced developers have more knowledge regarding how things should be written and how things work. Beginners lack this knowledge, and if they receive incorrect answers from ChatGPT, they might not be able to validate them and could treat them as correct.
Creating a Roadmap
Here, I asked ChatGPT to design a roadmap to become a front-end developer as a complete beginner.
The answer here is largely correct. It recommends starting with HTML and CSS, then moving on to responsive design, JavaScript, Git, build tools, and frameworks like React, Vue, or Angular. It also mentions SASS preprocessors and package managers. After this, it suggests learning about accessibility, performance optimization, and testing. Finally, it recommends building projects and gaining real experience, including personal projects and open-source contributions.
However, this list can be refined for a complete beginner. For instance, responsive design, Git, and build tools can be introduced later in the learning journey. SASS and package managers are also not essential for beginners. Junior developers typically do not need to focus on accessibility, performance optimization, or testing initially. Additionally, Gulp is outdated, and open-source contributions are not crucial for a junior developer.
I would not blindly follow such a list from ChatGPT if I were a complete beginner.
At the very least, you need to take this list and validate it on programming forums or ask an experienced developer. You don't want to spend time on technologies that you don't really need for your job.
This is one of the problems with ChatGPT. It is difficult for beginners to understand if the answers are valid or not.
Additionally, many people claim that ChatGPT can be your mentor and fully replace a person. I don't think that's true at all. A mentor is a knowledgeable person with lots of experience who can provide correct answers. If ChatGPT can't provide fully correct answers every time, then it's not a replacement. You must always validate everything that ChatGPT shows you. So, if you can find a knowledgeable mentor, it's always better for you.
Understanding Concepts
When ChatGPT really shines is in concept clarifications. Quite often, you encounter dry documentation on the official website that is not understandable at all, even for advanced developers. If you are a beginner, it is even worse.
Let's say that I don't know how useEffect
works inside React, and I really need to understand it in simple terms. Here we'll cover what useEffect
is, when it runs, what it does, and how you should use it. After this, you'll get a simple code example of how it works with a list of points about every line of code.
Most importantly, it's not just a single answer like in Stack Overflow because we can continue the conversation with follow-up questions.
Here, I additionally asked if useEffect
is synchronous or asynchronous. You receive a full clarification of its behavior, including a code example of the problem.
Code Explanation
Another important way ChatGPT can help you as a beginner is by explaining code within your project. Very often, beginners don't understand what is written, and it might be easier to go through the code line by line to grasp the meaning of each line. ChatGPT can be fantastic for this.
Previously, without ChatGPT, you would have needed to ask on Stack Overflow to understand every single line, in order to paint a clear picture for yourself.
Here, I've written some Angular code and I'm asking for clarification. I'm receiving an answer with line-by-line clarification. Additionally, it provides a summary of what this code does.
However, it's not always helpful.
Here, I've written another Angular code with newer features. It includes a computed property from Angular 17. ChatGPT believes that this code is not typical Angular code and that the computed
function is not a part of Angular syntax.
ChatGPT can't give us a correct answer to this question as it doesn't know all concepts of Angular, especially the newer ones.
Errors explanation
Another amazing way that ChatGPT can teach you coding is when you're stuck with some error.
For example, here I asked about an error I encountered: "Cannot read properties of undefined (reading 'map')". ChatGPT described why this error occurs, explaining that we're trying to use the map
method on something that is undefined. It also provided a list of steps on how to try to fix this issue: checking the array reference, inspecting the data source, handling async data, checking for conditional rendering, and how to perform debugging.
When you are a beginner, it really helps to receive a list of steps to debug an issue.
Improve Your Code
Another fantastic way for beginners to use ChatGPT is to ask it to improve their code.
Here, I asked to improve junior code and provided a lengthy React component. Typically, beginners' code is not written in a good way. ChatGPT can help you write your code at a much higher level. We received the improved version in a matter of seconds, and it is now considerably cleaner and more efficient. While I might adjust some parts slightly differently, overall, the code is now dry and clean compared to the previous junior code.
Planning a Project.
Where many people encounter difficulties is in creating their own projects. It's easy to start writing small chunks of code, but it's challenging to implement the entire project from start to finish. Many beginners simply don't know where to start or what to do. This is precisely where ChatGPT can help you.
You can simply ask for steps to implement a project. It's not requesting implemented code, but guidance on how you might proceed with the implementation. Typically, this guidance is really helpful.
Here, I asked for steps to implement a todo application with a list of todos and functionalities like edit, toggle, remove, and filters by active and completed tasks. We received clear, written steps such as project setup, installing dependencies, correct component structure, state management setup, required methods, and how to implement filtering correctly. It even includes testing, debugging, and deployment.
Most importantly, you can continue asking questions about implementing specific parts of your application, and ChatGPT can guide you through the implementation process. After writing some components, you can ask for the code and compare your results with ChatGPT's suggestions or ask for advice on how to improve your code.
So, I would say that ChatGPT can teach you how to code, but obviously, you need to understand how to use it correctly. However, it can tremendously help both beginners and advanced developers.
Want to conquer your next JavaScript interview? Download my FREE PDF - Pass Your JS Interview with Confidence and start preparing for success today!