Main image of article AI Tools for Programmers: What Can They Do for You?

Developers have begun building generative AI tools designed to help tech professionals with coding. But like any kind of tool, you need to be careful when deploying these AI-enhanced offerings. For example, you’ll still need to double-check any code produced by a tool—even if its creators claim its QA function will handle any bugs.

With that in mind, let’s look at some tools, including Replit and GitHub CoPilot. This should give you a good idea of which tools might best fit your current workflow.

Replit

Replit has grown from a tool for quickly trying out some HTML and Javascript into a full-fledged online IDE, complete with virtual servers for running your apps. It supports many languages along with a huge array of libraries and packages. The most recent version includes a really nice code editor that’s based on the same open-source code editor as Visual Studio Code.

In October 2023, Replit added AI tools to their code editor. As you’re typing, it will make suggestions for what to type next. On the surface, this is nothing new; code editors have offered autocomplete features for many years. But this autocomplete uses AI, taking autocomplete to the next level (in theory).

Here’s one quick example: I created a Python app in Replit. Then I created a new class called Person, which includes an _init_ constructor that takes three parameters: self (as every method needs), firstname, and lastname. I started typing this:

Class Name:

    Def __init__(self, firstname, l

As soon as I typed that lowercase ‘l,’ it predicted that the second parameter would be “lastname”, apparently based on the first parameter being “firstname”. It also added the closing parenthesis, but not the colon. So, I pressed Tab to accept the suggestion, and then typed the colon.

I pressed enter and it correctly suggested:

self.firstname = firstname

to store the first parameter into a member of the same name. I pressed Tab to accept it. And then lo and behold it suggested the following:

self.lastname = lastname

which, again, is exactly what I needed. So, I pressed tab again to accept it. Here’s the result:

class Name:

  def __init__(self, firstname, lastname):

    self.firstname = firstname

    self.lastname = lastname

Then I wrote code that created a new instance of Person. To my utter shock, the “autocomplete” filled in the last name for me. I created a variable Fred and started typing:

fred = Name('Fred',

I was stunned. It filled in the last name for me, which was exactly what I was planning to type: Flintstone. And of course, my next line was going to be a variable called barney; after I typed even less, just:

barney = Name(

It filled in the first parameter with Barney and the second parameter as Rubble.

Just to be more modern, yes, I also created a variable named Taylor. I typed:

taylor = Name(

And yes, you know what it suggested:

taylor = Name(firstname='Taylor', lastname='Swift')

I accepted Taylor Swift. (I then created two more variables: joe and donald. The names it offered were Joe Bloggs and Donald Duck. Okay, so it’s not political. Determined, I tried joseph instead of joe, and it offered Joseph Stalin. What? Okay, never mind, let’s move on.)

Yes, this isn’t particularly important to programming, but it shows that this tool clearly has a huge LLM (large language model) that includes a massive amount of information. Let’s try out its actual coding suggestions.

For the next line, I typed:

mynames =

And it filled in the rest of the line for me, predicting exactly where I was going with it:

mynames = [fred, barney, taylor]

It knew I was going to put the names into a list. (And interestingly it chose a list, rather than a tuple. Lists are mutable and generally more useful.)

Let’s take it a step further. As I type this article, I’m going to see if the AI tool can accurately help me write a function that loops through the names and prints out a string containing their first name, a space, and a last name. I haven’t tried this yet before I typed this paragraph. Let’s give it a go. I need to give it some hint as to what I’m up to, and so I’ll provide that in the function name. I’ll call it print_full_names. And here’s what I’ll type:

def print_full_names(names):

As soon as I typed the left parentheses, it filled in this part:

(names)

without a colon. (I wrote this function outside the class; as such, it correctly didn’t include a self parameter.)

I typed the colon. And then what did I see? This:

def print_full_names(names):

  for name in names:

    print(name.firstname, name.lastname)

Nailed it. Now I need to call the function using the mynames list. After the function I typed… (You can probably see where this is going):

print_full_names(

And it filled in the parameter for me:

print_full_names(mynames)

Perfect! When I run it, of course, it prints out the two full names:

Fred Flintstone

Barney Rubble

Taylor Swift

 

I also tried creating a function named print_last_names; as you might expect, I only typed def followed by print_last_n, and it filled in the rest (print_last_names) and ultimately code that loops through and prints only the lastname member of each item.

To further test the tool, I decided to write a function that sorts the names by first name and then prints out only last names. It needs some cues, of course, so I called the function:

def sort_by_firstname_and_print_only_last_names

I needed to type all that, as it couldn’t predict it. I then typed the left parentheses, and it provided names as the parameter. I tabbed through it, typed the colon, and then pressed enter. It suggested a couple of lines; for both I had to press tab. And look at what it generated after only typing the above line followed by various parentheses, tabs, and colons:

def sort_by_firstname_and_print_only_last_names(names):

  for name in sorted(names, key=lambda name: name.firstname):

    print(name.lastname)

And while it was waiting for me to type this into this document, it offered another line:

sort_by_firstname_and_print_only_last_names(mynames)

So, I pressed Tab to accept it and ran it. Then I ran it. Here’s the output for this particular function:

Rubble

Flintstone

Swift

It worked. It wrote a function, including an advanced Python feature called a lambda function, and it successfully sorted through the list based on first name (Barney, Fred, Taylor) and printed out only their last names. All based on the function name I carefully wrote to provide cues to the AI.

GitHub Copilot

The biggest entry for programmers in the AI tools world is very likely GitHub Copilot, which was developed by OpenAI (who created ChatGPT) alongside GitHub. It’s available as a plugin for several IDEs, including Visual Studio Code, Visual Studio, and JetBrains.

Copilot is also not free; it requires a subscription. (At the time of this writing, an individual subscription is $10 per month or $100 per year.) The following is all based on the individual plan.

To use Copilot in VS Code, you need to first activate Copilot on the GitHub website. Go here and click Get Started With Copilot; then in the individual plan you’ll see “Start a free trial.” Once you fill in your information, you’ll be ready to use Copilot in different IDEs. Let’s look at Visual Studio Code.

Open VS Code, go to the extensions, and type in Copilot. You’ll see GitHub Copilot at the top; click it and click the Install button. You’ll then see a popup that says, “Sign in to use GitHub Copilot.” Click the blue Sign In button, and you’ll be taken to GitHub in your browser. You’ll see a popup message asking you to allow; click the Allow button. This will take you to a GitHub page stating, “GitHub for VS Code is requesting additional permissions.” Click the Authorize button; you’ll then see another popup asking to return to VS Code. Then you’ll be good to go.

When you open a code file (such as one with a .py extension for Python) you’ll see the message “Press Ctrl + I to ask GitHub Copilot Chat to do something.” (That’s Ctrl plus uppercase eye.)

I typed in: “Create a Python class called Person that contains two members, firstname and lastname, and a constructor to initialize those two members.” Lo and behold, it created a class identical to what we saw in the Replit example, except in this case I accidentally called it Person rather than Name, and it pasted that code right in the file.

Next, I asked it to “Create a variable called People that holds a list.” Unfortunately, it created this inside the constructor function. So I tried again: “Create a variable in the global scope called people that holds a list.” It still tried to make it inside the function. Okay, forget that; it’s easy enough to go outside the function and simply type:

people = []

And as soon as I did, it offered up a suggestion to create a new instance of Person with first name “John” and last name “Doe” and add it to the list like so:

people.append(Person("John", "Doe"))

 

Okay, cool, I’ll accept that by pressing Tab.

Now let’s do several more names. instead of going for Fred Flintstone and contemporary pop friends who may or may not be great singers, I pressed Ctrl + I and asked it to create a dozen instances. I typed: “Please add a dozen more people to this list called people.”

And it delivered. Remember, this is Generative AI, and so it can read and parse language easily. And it did!

people.append(Person("Jane", "Smith"))

people.append(Person("Michael", "Johnson"))

people.append(Person("Emily", "Brown"))

people.append(Person("David", "Davis"))

people.append(Person("Olivia", "Miller"))

people.append(Person("Daniel", "Wilson"))

people.append(Person("Sophia", "Taylor"))

people.append(Person("Matthew", "Anderson"))

people.append(Person("Ava", "Thomas"))

people.append(Person("Andrew", "Martinez"))

people.append(Person("Isabella", "Hernandez"))

people.append(Person("Joseph", "Lopez"))

 

The names are pretty generic, but that’s okay. (For what it’s worth, I deleted all those lines and instead typed: “Please add a dozen more people to this list called people. Make sure it's multicultural.” And it did an okay job.)

Next I asked it: “Create a function that takes a list of Person instances and sorts them by first name and prints out only last names.”

It did a good job, but didn’t name the function the way I would have preferred. The function name it chose was “sort_and_print_last_names”. The code inside the function, however, was almost identical to what Replit produced:

def sort_and_print_last_names(people):

    sorted_people = sorted(people, key=lambda person: person.firstname)

    for person in sorted_people:

        print(person.lastname)

I next wanted a line to call the function. As soon as I typed “sort” it filled everything in for me:

sort_and_print_last_names(people)

Nice! Save it, run it, and it works!

More Tools

Copilot is easily the most popular tool, and it integrates into the more popular IDEs. But what other tools are out there for your AI-assisted coding needs?

Remember that these tools use Large Language Models (LLMs) that are trained to understand programming languages such as Python. What that means is other tools are likely to provide similar results. As you saw here, the AI embedded into Replit isn’t all that different from what’s in Copilot; the difference is how we interacted with it.

But that’s about writing code. There are additional tools for tasks such as bug detection and code reviews. Briefly, here are some:

Tabnine: This is an AI tool that helps “fill in” what you’re about to type (when you press Tab). That’s similar to what Replit offers. But like most generative AIs, it lets you type in a description first of what you need, and then it provides code. Tabnine includes a free 90 day trial with premium plans starting at $12 per month.

DeepCode: This tool uses AI to analyze your code and look for problems.

SonarLint: The key here is the word “Lint.” That comes from the concept of a code linter, which checks for styles and syntax. Advanced linters can even look for bugs and other problems. In other words, SonarLint is a next-level linter that incorporates AI into its linting processes.

Finally, let’s consider one more AI tool. Don’t forget documentation! Your code needs good documentation, and there’s a tool called Doxygen that helps with that. What’s interesting here is that this tool can read your code and then produce documentation based on what it sees.

Conclusion

AI tools have gone through incredible advances over the past few years. Generative AI has emerged as one of the biggest technological advances in recent history. However, no matter how advanced these tools are, don’t forget that you still need to carefully read, understand, and critically review any code it offers. Did you understand the lambda function aspect of the sort algorithms in the Python code shown here? If not, take time to learn it. And then ask yourself if the code is, in fact, correct and does what you need it to.

Treat AI as a helper who knows maybe just a bit more than you on some things, and maybe a bit less than others. Be critical of it. Never submit code to a production repository without testing it yourself.

But after you understand these caveats, these AI tools can greatly speed up your development time. Learn them, understand them, use them correctly, and your productivity will greatly increase.