I’m a web developer for a development agency based in Birmingham UK, and have always thought about ways to increase speed of writing everyday code. Because, as with any job, there are parts that you find yourself doing over and over but they slow your progress or can distract you. So can AI help me to improve my efficiency of code writing, allowing me to focus more on the logic and complexities, rather than the basic level code I write daily?
In recent times AI has been helping us with many different jobs. From answering our random questions, to generating images for us. But there is a rise in tools that help software developers. The leading force is GitHub Copilot.
It works differently to ChatGPT and other prompt based tools. Instead, Copilot reads what has been programmed already and preempts what the programmer is going to need. From boilerplate code such as basic file layouts, to differing logic based on where the cursor is. It can also generate large chunks of code from comments that are left through the code by a developer. The more detailed and clear the comment the better the quality of the code that is rendered, just like with questions to ChatGPT.
Below is an example of this in use, I asked for it to make a class, with 3 attributes. It did this as asked, with a few undesirable additions, for example the comments “make a function that returns the string” this is more like what a developer would type to encourage Copilot rather than something we would want to come from it. However, if comments have been left in peoples code, this is where it will have learnt this behaviour from.
The amount of time that this saves is incredible. But, does this make developers redundant? Simply put, no (and not just because Iโm a developer myself), let me explain…
Developers have the best contextual knowledge of the platform they are working on, additional considerations such as quirks within a system, and also what their end goal is. Working across several files, keeping to the best practices. Copilot uses code from public repositories, as well as code from the current project to work out what code to provide. Though just like the prompt based AI tools like ChatGPT, it is only as good as the code it gets to learn from. From time to time it will over complicate some logic, or give a code snippet that is suboptimal for performance, and sometimes it completely misses the mark with what is required.
The image below shows how I would tweak the top part, based on the knowledge of the project which allows for a more succinct way to write this piece of code.
At this point, Iโm sure people are thinking other than it getting it wrong from time to time how can this be a hinderance. Well some developers can find its prompts annoying, because it does just appear if you stop typing. It applies to the file if you hit tabโฆ which developers do a lot to keep our code neat and readable as can be seen in the above images. You also have to learn how to add comments to get whole functions to be written for you, but this is no different to learning how to ask ChatGPT to properly format some text for you.
GitHub have also announced that they are expanding the tool to allow creation of files, projects and have a chat prompt to ask for code vs having it inline. So for those developers who struggle having it inline, they will be able to use the prompt when they choose to ask for help from CoPilot.
Final thoughts
As with most things, itโs down to a personal preference as to whether this hinders or aids people. When it comes to basic level like everyday code, itโs very efficient for a developer, but as the code gets more complicated it gets harder for AI to determine what we are going to do. Also, as it wonโt correct code youโve selected from it, it becomes a little cumbersome on the more unique software platforms. Overall though, the benefits of having such a tool running with you as you work, far outweigh, in my opinion, the slight hinderance it causes.