ChatGPT vs GitHub Copilot

ChatGPT vs GitHub Copilot [Real Code Comparison]

If you’re an avid tech user, you’ve probably heard of ChatGPT and GitHub Copilot – they’ve seemingly come from nowhere.

Both are incredibly powerful coding tools that can help developers create their projects from the ground up quickly and efficiently. 

However, after comparing the two, we came to the conclusion that ChatGPT was much better as your coding companion than Github Copilot. This was simply because the coding responses were better, and the accessibility of a SaaS product like ChatGPT could be used anywhere you had Internet.

This post will look at how good each one is on code, their costs, how accessible they are, and an overall review at the end. 

To see which is better, we will compare them over five prompts and see who does the best. 

With our custom-made analysis, you’ll be able to determine which of these two products is the right choice for you and your coding projects.

Stay tuned as we compare ChatGPT vs. GitHub Copilot!

This one’s a good one!

code on screen


ChatGPT vs. GitHub Copilot: Writing Code

Winner: ChatGPT, but not really apples to apples.

When comparing ChatGPT to GitHub CoPilot, it’s not exactly an even comparison. 

This is because GitHub CoPilot is designed to help and code with the user, while ChatGPT receives a coding question and simply answers it. 

That being said, ChatGPT was remarkable in its ability to answer questions about Python functions.

I think it actually did better than I could have with the same coding set.

It provided detailed responses and explanations that I would’ve had to sit down and think about for a long time (while it responded in about 3 seconds). 

While ChatGPT cannot offer the same interactive programming experience as GitHub CoPilot, it can undoubtedly provide a great deal of assistance regarding coding questions.

And to be honest, I prefer ChatGPT’s style more, where it gives you an answer and allows you to use and edit that code to fit your style.

This would be much faster for ideation and coding than having an AI tool coding with me as I go through the prompts.

Overall, both tools are handy for developers and coders who need assistance understanding or implementing code.

Prompt: Write a function that checks if the user made a mistake typing in a phone number and returns the correct number


GitHub Copilot:

def correct_number(number):
    if number[0] == '1':
        return number
    else:
        return '1' + number


ChatGPT:

import re

def check_phone_number(number):
    # remove any non-digit characters from the input string
    digits = re.sub(r'\D', '', number)
    
    # check if the resulting string is a valid phone number
    if len(digits) == 10:
        return digits
    elif len(digits) == 11 and digits[0] == '1':
        return digits[1:]
    else:
        # return None if the input is not a valid phone number
        return None

Write a FASTapi endpoint that parses the payload and returns half of it


GitHub Copilot:

def half_payload(payload):
    return payload / 2 

ChatGPT:

from fastapi import FastAPI

app = FastAPI()

@app.post("/half_payload")
async def half_payload(payload: dict):
    half = {k: v for i, (k, v) in enumerate(payload.items()) if i < len(payload) // 2}
    return half

Create a function that represents the Fibonacci sequence


GitHub Copilot:

def feb(n):
    if n <= 1:
        return n
    else:
        return(feb(n-1) + feb(n-2))


ChatGPT:

def fibonacci_sequence(n):
    """Generate the first n terms of the Fibonacci sequence."""
    if n <= 0:
        return []
    elif n == 1:
        return [0]
    else:
        sequence = [0, 1]
        while len(sequence) < n:
            sequence.append(sequence[-1] + sequence[-2])
        return sequence

Build a torch model that takes in an image and returns the predicted class


GitHub Copilot:

def predict_class(image):
    torch_model = torch.load('model.pt')
    return torch_model(image)


ChatGPT:

import torch
import torchvision.models as models
import torchvision.transforms as transforms

# Load the pre-trained ResNet18 model
model = models.resnet18(pretrained=True)

# Set the model to evaluation mode
model.eval()

# Define the transformations to be applied to the input image
transform = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize(
        mean=[0.485, 0.456, 0.406],
        std=[0.229, 0.224, 0.225]
    )
])

# Define a function that takes in an image and returns the predicted class
def predict_image_class(image_path):
    # Load the image and apply the transformations
    image = Image.open(image_path)
    image = transform(image).unsqueeze(0)
    
    # Make a prediction with the model
    with torch.no_grad():
        output = model(image)
        _, predicted = torch.max(output, 1)
    
    # Return the predicted class
    return predicted.item()

Write a recursive function that finds the empty square in a grid and returns the coordinates


GitHub Copilot:

def grid_solver(grid):
    for i in range(len(grid)):
        for j in range(len(grid[0])):
            if grid[i][j] == 0:
                return (i, j)
    return None


ChatGPT:

def find_empty_square(grid):
    for row in range(len(grid)):
        for col in range(len(grid[0])):
            if grid[row][col] == 0:
                return (row, col)
    return None

def find_empty_square_recursive(grid, row=0, col=0):
    if row >= len(grid):
        return None

    if grid[row][col] == 0:
        return (row, col)

    if col < len(grid[0]) - 1:
        return find_empty_square_recursive(grid, row, col + 1)

    return find_empty_square_recursive(grid, row + 1, 0)

# Example usage:
grid = [
    [1, 2, 0],
    [4, 5, 6],
    [0, 8, 9]
]

print(find_empty_square(grid))  # Output: (0, 2)
print(find_empty_square_recursive(grid))  # Output: (0, 2)


ChatGPT vs. GitHub Copilot: Cost

Winner: Tie

When comparing the cost of ChatGPT vs. GitHub Copilot, we’ve spent some time mulling over it, and we think it’s a tie. 

While there is a free version of ChatGPT, it seems to always be at capacity, so you may not be able to use it when you need it. 

This led us to have to purchase ChatGPT Plus for $20 a month.

On the other hand, GitHub Copilot is only $10, which is half the cost of ChatGPT.

However, by spending that extra $10 for ChatGPT, you get many more options to use the tool outside of coding as a general generative text tool.

We couldn’t come to a conclusion here at EML on which had the better pricing model, as it seems both are similar in price for the value that they bring.


ChatGPT vs. GitHub Copilot: Accessibility

Winner: ChatGPT

Regarding accessibility, ChatGPT is the CLEAR winner over GitHub Copilot. 

This is because ChatGPT is a SaaS (Software As A Service) and, therefore, can be used anywhere at any time, as long as you have access to the internet (and a browser?). 

On the other hand, GitHub Copilot must be integrated directly into an IDE such as iNeovim, JetBrains IDEs, Visual Studio, or Visual Studio Code to use it.

While every dev in the world generally uses an IDE, as a machine learning engineer, I’m constantly rotating around to different coding platforms like VIM and SSHing into servers.

Once I’m outside my IDE, I’d no longer be able to use it!

Since ChatGPT does not require integration with an IDE, it makes it easier for developers to quickly get up and running with their development process without worrying about setting up new software or learning to work with tools inside their IDEs.

And the best part is I can use it on computers that aren’t mine.

With GitHub Copilot, if I’m using any other computer that isn’t mine, I’m pretty much unable to use the tool.

With ChatGPT, when I’m at the library, I can access OpenAI’s website from the internet, log in, and get started using the tool in under 30 seconds.

ChatGPT obviously has better accessibility and can be accessed from far more places much more conveniently than Github Copilot.

open sign


ChatGPT vs. GitHub Copilot: Overall

Winner: ChatGPT

When it comes to AI-powered coding assistance, as of right now, ChatGPT is my clear favorite. 

I prefer the immediacy and simplicity of its “give the whole answer” style compared to Github Copilot’s “code with you” approach. 

The convenience and accessibility of software as a service (SaaS) solutions make it worth the extra $10 per month. 

And finally, the coding comparison wasn’t really that close.

I was blown away at how good ChatGPT was at answering these coding questions correctly in under 2-3 seconds. 

All things considered, I believe ChatGPT is ultimately a better choice than GitHub Copilot when it comes to coding and generative text in general.

thumbs up in an office

 

Other ChatGPT Articles

We know that ChatGPT has taken the world by storm. And by doing this, it’s also created a TON of confusion.

Don’t worry; we have some guides to help you.

Stewart Kaplan

Leave a Reply

Your email address will not be published. Required fields are marked *