DEV Community

Cover image for Stop Using AI, Use These Proven Coding Practices instead
Tech Vision
Tech Vision

Posted on

Stop Using AI, Use These Proven Coding Practices instead

Using an AI code assistant isn't like having an expert programmer do all the hard work for you. After a year of using it, I've come to see its limitations. In this post, I'll show you how relying too much on AI can slow down your progress and pose risks. Instead, I suggest three underappreciated practices that can help any developer improve.

If you prefer the video version, here is the link 😉

AI Slows you down

To learn how to cycle, you simply jump on a bike and give it a try. The same principle applies to learning to code or use a new library or technology. You'll make mistakes, but you'll learn from them. Ultimately, by doing the hard work, you'll acquire new skills in a lasting way.
However, using an AI code assistant may deprive you of this crucial element of the learning process. It can slow your progression because it eliminates the opportunity for growth through trial and error.

You can't trust AI

Yes, AI is great at giving you quick answers. But a quick answer doesn't necessarily mean correct. AI models are trained on real-world data samples that may contain incorrect information. The answers provided are more or less the average answer obtained from the available data and are not specifically tailored to your needs.

AI code assistants have another limitation that prevents them from coming up with the correct answer every time. The code assistant works with a limited context. Sometimes, the context is limited to the source file you are working with. But even if the model takes the entire source code as context, something will always be missing.

An AI code assistant doesn't know the initial requirement, the project history, or the end user's behaviour. When you code, you translate an intention, an expected behaviour, into machine instructions. And that can be very subtle because those intentions and requirements come from humans. Humans don't give clear instructions. Sometimes, they don't even know what they want. Your job as a developer is to convert fuzzy, unclear requirements into a set of precise machine instructions.

That's my second main issue with AI: You can't fully trust the accuracy of the answers it gives you. Please do not fall into the trap of thinking that an AI code assistant is an expert developer; it simply can't be because it takes more than writing code to be an expert. It has to be very clear in your mind that an AI code assistant is just that, an assistant.

AI won't take responsibility

AI code assistants usually generate correct answers, but what happens when they don't? Who's responsible if AI-generated code leads to bugs?

You are still the one responsible for the code you publish, even if you didn't write it yourself. If you decide to use code you don't understand just because it seems to work; you still need to maintain it. What happens when you need to make changes or debug the generated code?

The third reason why I discourage AI code assistants is if you put the AI assistant in charge. Not only that's a not professional attitude, but it can also lead to real-world consequences for the product you're building and your career. What if you join a company where AI is not allowed? So make sure you stay the one in control.

Ok, you want to stay in charge; you want to put in the hard work yourself because, ultimately, that will make you a better programmer. But everyone gets stuck at some point and needs help. Before jumping straight to chatGPT, I will give you three alternatives that can be much more beneficial for you, especially if you care about your career progression.

Read Documentation

Coding requires knowledge of programming languages, libraries, and frameworks, as well as building, running, and deploying code. And that's a lot. Fortunately, the creators of these tools provide instructions to help. There is genuinely fantastic documentation out there. I'm not suggesting you go out there and read all of it or start reading programming language specifications.

Here is what I recommend you do. If you use a library, open the documentation and read the titles. Go quickly through the different chapters; if there are some diagrams, images, highlighted sections, or summaries, read that as well. When you do that, you become aware of what's available and what's not.

If you've used ChatGPT, you know that it's very eager to give you an answer no matter what. If you ask for a feature that doesn't exist, it might hallucinate and give you misleading answers.

My first recommendation is to skim-read documentation. You'll gain more awareness of what's possible, and next time you're stuck, you'll know where to find the answer. And you'll know you can trust that answer.

Use a good old Google search

However, you can't always find answers in the documentation. Sometimes, you just don't know where to find the solution. This may be slightly controversial, but I recommend a good old Google search.

When you get a result from Google, you know the source and the context in which this information is produced. For example, on our beloved StackOverflow, you can see how old posts and answers are. Not only that, you can also see the back and forth in the comments and different versions of an answer.

Yes, of course, an AI can give you an answer, but if you are not actively asking for alternative solutions or nuances, you most likely won't get them from an AI-generated answer. It is undoubtedly the most challenging and slowest, but it leads you further.

Helping Others

I'm sure that has already happened to you, but sometimes you get asked a question, Google it, and give the answer. Then you appear to be smart when, in reality, you just google it. Surely, the person asking the question could have done the same. That shows that knowing how to search and where to find the relevant information is a skill in itself.

And that brings me to something that I only realised recently. It's something that we all tend to do naturally. But turning it into a habit can transform how others see you. And that's simply helping others. When you struggle with a piece of code and finally make it work, when you spend hours on a complex concept and it finally clicks, consider sharing. One very powerful way of consolidating that new skill or piece of knowledge is to teach it.

But there are other ways you can help: write documentation, do pair programming, and review code. When you focus some of your attention on solving other people's problems, good things happen. You feel good, and people want to work with you. People around you will value your opinion and give you more responsibilities.

But it all starts by putting in the effort, doing the work yourself, and not taking shortcuts.

Let's be clear: I'm not against using AI as part of your workflow. AI code assistants will become an unavoidable tool for every developer as they improve. But just like every tool, it's good to understand when to use it.

Top comments (0)