Weekly Shot 7 — AI that can write code?

Weekly Shot
5 min readJul 4, 2021

Are machines going to write code for themselves in the future? Is automating machines also going to get automated? These do seem quite possible now that tools like GitHub Copilot are popping up. This week we’ll be taking a look at the capabilities of GitHub Copilot with a small commentary on what to expect in the near future.

What is GitHub Copilot?

GitHub recently unveiled it’s brand new product — GitHub Copilot. Marketed as a “Pair Programming” tool for developers, it is intended to aid developers in writing code quickly and remove the need to manually write a lot of things. It is available as a technical preview as of now and GitHub says it plans to commercialize it once testing is completed. We managed to get hands-on with this tool and needless to say, it is as good as they say it is.

So what can it do?

Copilot can suggest code in a lot of different ways. Let’s look at a few ways it can do that. (Note that the grey text that appears is the code suggested by Copilot).

In the above scenario, as soon as I write a comment on what the subsequent code should do, Copilot immediately suggests appropriate code based on my comment.

One more way Copilot suggests code is based on function names. When I defined a function with the name “generate_random_string”, it understood my intent and aptly gave me code to generate a random string.

It also understood that I had imported the Crypto module so it suggested the code based on what I had already written and imported.

One thing that developers, including me, find really tedious is writing repeated and boring code. To write such code, I would usually resort to searching for the code online and copy-pasting it. This is essentially eliminated with Copilot. In the above example, Copilot understood that I wanted all the numbers and alphabets in lists and automatically suggested it to me.

If you don’t like a suggestion, you can ask Copilot to fetch 10 more suggestions and pick from those (demonstrated below).

Copilot is designed in such a way that it understands what to suggest based on the context. It understands the way previous code is written and implements that same style in its suggestions. This feature, in my opinion, is what sets Copilot apart from other code helpers and sets a new bar in terms of code suggestions. It can understand what libraries I have imported, functions I have previously written, style of variable names, the content of functions and correlation to its name, and a lot more. This is only going to get better as development continues.

How does all this work? What are the possibilities?

All the suggestions are powered by a cutting-edge AI model developed by OpenAI and trained on billions of lines of code available publicly. Copilot takes context from your editor, runs it through the model to get predictions and provides them. GitHub says that all this is done completely securely and anonymously.

With this level of code help available, the need to constantly take help from a search engine is drastically reduced. I don’t need to manually search for boilerplate code or repeated functions when it is directly available in my editor with a single comment or function name. I also don’t need to constantly read the documentation for a new library I am learning.

Risks, responsibilities and the future of software development.

Since the AI is trained on publicly available code and given the fact that every line of code can’t be manually checked for bugs, security issues and errors, it is entirely possible that the suggestions provided can sometimes be wrong, outdated and even outright dangerous. There can also be cases where personal info in someone’s code is auto-suggested putting the developer at risk. This means that YOU the developer needs to make sure that your code conforms to the standards (there are a lot of tools available for this like Dependabot and CodeQL) and be aware that you are in charge of the code you write.

There is no doubt in the fact that machines are getting better day by day at automating tasks and replacing the need for humans in many areas. But a future where machines write code for themselves without a need for a developer might still be ways away but fast approaching. Let’s keep a lookout for more technologies like this and pray that our AI overlords will show us mercy when and if they take over.

We hope that this was an informative article and gained some insight into what’s in store for the future. If you have any further questions, be sure to leave them in the comments.

As usual, if you are looking to support us directly and help us in continually publishing these articles, consider our Patreon and Buymeacoffee pages. Thanks and have a wonderful day :)

--

--