A Programmers Guide to AI

About This Site


With recent advancements in AI, programmers now have many AI programs to help them with their coding. The two that will showcased in this website are ChatGPT and Github Copilot.

Why Use AI?


Sometimes as programmers, we may not have the experience to be able to tackle problems. With AI we can get effective solutions immediately. These tools should not be used to cheat in a classroom or for anything like that.

  

ChatGPT

ChatGPT is an AI tool developed by OpenAI that can assist with a variety of tasks. For programmers this can include automation of tasks, creating code solutions for problems, creating documentation, answering programming-related questions, and more. And if the answer you received isn't correct or you want to see another approach, you clarify the question and ask ChatGPT to compute another answer. In some cases the AI is unable to, this is one of the downsides to ChatGPT.

Example:

  Input: "Write a function to find the distance between 2 points?"

ChatGPT: 

import math

  def distance(x1, y1, x2, y2):

     return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)

As you can see given a problem ChatGPT will provide a solution. Alongside this solution, the code is also explained by the AI. This is one example of how ChatGPT can be used. 

Github Copilot

Github Copilot is an AI tool developed by Github. It's focused only on programming related tasks and is integrated into text editors like Visual Studio Code. It's described as an AI pair programmer. What this means is it suggests code as your code and you can add comments in the code asking it to do a task.


Examples:

//Write a function to add 2 numbers

def add(a,b):

    return a+b

//write a function to subtract 2 numbers

def subtract(a,b):

    return a-b

Here I used comments to ask GitHub CoPilot to complete tasks for me. I can ask it to add documentation or write the code in a different way.

ChatGPT vs Github Copilot

Both tools are great and should not be viewed as, pick one or the other. Instead both can be used in different scenarios to get the most out of them. Since copilot is integrated into your coding environment, it works better for more context heavy tasks. Whereas ChatGPT is better at context free tasks.