Say farewell to Rubber Duck, your new AI coding buddy is here!
If you’ve been coding for a while, I’m sure you already heard of rubber duck debugging. Explaining your code to someone (or in this case a rubber duck) can help tremendously in finding and understanding flaws in it. It can be even better if you have somebody else to talk it through with, since they can share their own ideas with you, or if developing a new feature, they can even have a much easier way of implementing it than you previously thought. That is the whole point of pair programming – two people working together to plan and develop pieces of code overseeing the others’ work.
If you used this method already and switched back to coding alone after, you might miss those thoughts and ideas that popped up while you were hard focused on a line of code. This is where the newest solutions I’ll be writing about come in handy. Nowadays there are new AI pair programmers popping up all around the internet. Amazon just introduced CodeWhisperer a few weeks ago to compete with GitHub’s tool, Copilot.
GitHub released Copilot in 2021, and made it generally available late June of 2022. Copilot can help in a variety of situations. It’s a tool that completes code intelligently, similar to how the GPT-3 model of OpenAI can predict the next word in sentences, or even complete them. It’s basically autocomplete on steroids. A lot of them. There are many times you google even the most basic stuff after years of developing. Copilot can almost completely eliminate this and save you a lot of time.
You don’t remember the name of a built-in function? It doesn’t matter, Copilot will use the context of your work and there is a really high chance it will recommend just that exact piece of code you need.
You need to return every second element from an array of numbers but only if they are even? It might be easy to code, but its even easier to just tell Copilot to do it. It even helps you in writing comments that you will use to tell it what to do. (Which scares me a bit sometimes…) In the pictures below, you can see it in action. I didn’t write a single line of code, only the comments. You might also notice that I didn’t even have to finish the first comment, it autocompleted the comment itself.
It can help with much more than these examples: e.g. more complex code, API calls, generating random data for you. It even knows the responses of commonly used APIs, so you can write code that parses them in seconds, without even opening their documentation. (Not saying that it’s a good idea, but definitely possible!). It will also adapt and follow the conventions you use in your codebase, so it feels really natural, I’ve used it to refactor code already and it worked flawlessly.
Obviously, you have to understand every piece of code it writes and the limitations it has, you can’t just trust it blindly. It can and will make mistakes, or won’t autocomplete your code the way you want it at all. It can also write code that looks okay syntactically, but doesn’t perform the action you wanted it to do. You have to notice these mistakes and correct them. To do that, you have to treat Copilot as it is – a tool that helps you, not a miracle that writes code instead of you.
Developers can learn a lot just from using it. The model it uses was trained on millions of projects, and it will try to recommend the best, most common parts of them to you. You need to have a fair amount of experience before you can truly feel its effect though. That being said, I would not recommend it for newer programmers since it can be a trap until you understand the basics and have seen a good amount of projects. However if you feel like you are experienced enough – try it! It’s an amazing tool that can speed up the work of even the most senior programmers.
That wraps up a quick introduction to AI pair programmers, specifically Copilot. Try it yourself to see the amazing things it can do! (https://github.com/features/copilot)
Have fun coding! Or telling Copilot to code for you I guess.
In the world of software development, code interpreters have emerged as a revolutionary tool, offering developers a versatile and efficient approach to writing and executing code. Unlike compilers that translate code into machine language before execution, code...
Last summer, the concept of a 4-day workweek gained significant attention, both internationally and within Hungary. Following the footsteps of multinational corporations, several companies in Hungary announced pilot tests to examine its effects. As a software...
When developing software, it’s natural to think of features and functionality first. However, that can lead to incomplete products or services, which is why UX designers prefer the “user first” approach. Wireframing takes place quite early in the design place, when...