Member-only story
AI Titans: DeepSeek, Copilot, ChatGPT — Decoding the Best in Code Assistance
Since the code language models are rising, as a developer I’m using them in a daily basis and today I did an experiment on my top 3:
- DeepSeek
- ChatGPT
- GitHub Copilot
if you are not a Medium premium member, you can read it for free here.

I wrote a function that does not follow best practises, have performance issues, using redundant loop, bad variable naming, … a terrible code:
function maxNum(arr) {
if (arr.length === 0) {
return null;
}
let max = arr[0];
for (let i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
for (let i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
console.log("The max number is: " + max);
return max;
}
// Example usage
maxNum([3, 5, 1, 9, 2]);
And then used the same prompt to refactor it
Refactor this function to improve the performance and use best practises: My awful function
And here are the result from imo the worst to the best:
GitHub Copilot
Apart from the result of this experiment, I kind of disappointed many times when I used Copilot, and this time also disappointed me

Few points why I didn’t liked it:
- Throws an error for empty arrays, returning
null
is often more flexible and aligns with common JavaScript practices for handling missing values - Including logging inside the function can be seen as intrusive. Functions should generally avoid side effects like logging, making them more reusable and testable.
ChatGPT
Here is what ChatGPT come with:
