Do ChatGPT and Copilot make developers forget the basics?

How Artificial Intelligence makes developers lazy

Auriga Aristo
Indonesian Developer
4 min readJan 27, 2023

--

Photo by Hitesh Choudhary on Unsplash

These days, we have found many AIs created to help people achieve something. Several years ago, we heard about image recognition and object detection used in Tesla electric cars. Then, there is Grammarly to check your grammar in English text. After that, there is Midjourney to convert text into images. Lastly, we heard about ChatGPT, an AI that can answer your questions. As time goes by, AI becomes more brilliant. Smarter AI is good, but something that intrigues me. People are getting lazy.

Before, we learned the basics of coding through books or websites. Then, we found out how the code was working and how to improve our code by understanding every syntax in our code. But junior developers nowadays search for the issue and copy-paste the answer to their code without knowing what is happening in their code. As a result, they become lazy when they use AI to generate their code.

I will explain about 2 AI used by many developers, specifically GitHub Copilot and ChatGPT. Let me explain first what these AI do.

GitHub Copilot is an AI-powered code completion tool designed to help developers write code faster. It uses machine learning to predict and suggest code based on the developer’s current codebase context and past coding behavior. It is designed to improve the developer’s workflow by reducing context switching and increasing productivity. It uses the GPT-3 model and runs on GitHub’s servers.

ChatGPT is an extensive language model developed by OpenAI. It is trained on a massive text dataset and uses deep learning techniques to generate human-like text. It can be used for various natural language processing tasks, such as answering questions, rendering text, and summarizing information. It is designed to understand the context of a conversation and can continue it or develop coherent and consistent text with the provided input.

For the most straightforward problem, I’ll explain sorting. If we talk about sorting, we know there is bubble sort, insertion sort, quick sort, and many more. To choose the best sorting algorithm, we learned about time and space complexity, big O notation, and how the algorithm works.

Time and Space Complexity for Sorting Algorithms

Now let’s see what these AI do for us… I use Java for this and my keyword is “sort an integer array list”

Github Copilot

1st attempt

public static void sortArrayList(ArrayList<Integer> list) {
Collections.sort(list, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return o1.compareTo(o2);
}
});
}

Pretty straightforward, just comparing each value with another

2nd attempt

public static void sort(ArrayList<Integer> list) {
int n = list.size();
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (list.get(j) > list.get(j + 1)) {
int temp = list.get(j);
list.set(j, list.get(j + 1));
list.set(j + 1, temp);
}
}
}
}

For those who don’t understand the code above, it is bubble sort. It’s the worst algorithm to sort an enormous array of data.

ChatGPT

1st attempt

public static void main(String[] args) {
ArrayList<Integer> numbers = new ArrayList<>();
numbers.add(3);
numbers.add(1);
numbers.add(2);
Collections.sort(numbers);
System.out.println(numbers); // Output: [1, 2, 3]
}

It looks like the first attempt of Copilot, but more simple.

2nd attempt

public static <T extends Comparable<T>> void sortArrayList(ArrayList<T> list) {
for (int i = 0; i < list.size() - 1; i++) {
for (int j = 0; j < list.size() - i - 1; j++) {
if (list.get(j).compareTo(list.get(j + 1)) > 0) {
T temp = list.get(j);
list.set(j, list.get(j + 1));
list.set(j + 1, temp);
}
}
}
}

Same as the second attempt, but it is kinda difficult to read, especially if we don’t have much experience to code using Java. What is T?

The answer above is not wrong, it is correct and you can use it easily in your code.

In the implementation, Copilot generates the code in the IDE without giving any explanations. However, ChatGPT also explains the code, including providing an example and how to use it in our code, but you have to chat the bot to get the information that you need.

ChatGPT Answer for 1st attempt

Without the basics, developers can use the most straightforward code and keep forgetting the basics. For example, although many sources explain the sorting algorithms, I don’t think they will search like “how to use heap sort?” So now, my question is, “do you know what algorithm is used for Arrays.sort()?

Arrays.sort() in Java uses a sorting algorithm called Dual-Pivot Quicksort.

I’m not gonna explain what is Dual-Pivot Quicksort.

Does the AI wrong? No.
Should we know what every line of code does? Yes, it’s better.

Why? Every line of code is essential if you create a big project one day. The more modular and better time and space complexity is preferred. Don’t make yourself or others not understand a function in the future. Start learning from the basics.

BONUS

It’s just a meme, don’t do this in your projects. You won’t know if it crashed or got so many errors one day.

--

--

Auriga Aristo
Indonesian Developer

4+ years in Backend Developer | PHP, Java/Kotlin, MySQL, Golang | New story every week