November 5, 2022
We have all heard about GitHub co-pilot, code automation and how is it going to end the need for a developer. We all know how it works, it works on data basically they have accumulated all the GitHub repositories and the AI search, learn and improve on that data.
I know I am late to the party, but I have been using GitHub co-pilot in my Vscode for about a month now. It is a very powerful tool and can make things very much easier, but let’s get things in perspective.
One of the things that I loved about the GC is its ability to autocomplete, it's not just a stupid autocomplete that we have in the Vscode extensions, it actually kind of knows what you are going to write next. It has helped me majorly in two areas.
We all know how frustrating it is to write CSS colons class names and you always get confused between comma and semi-colon thinking it was an Object. This is very well handled by GC and will save a lot of your time, you just write a comment with all the CSS properties and it will generate it for you in a CSS format.
For JS it is really a blessing, It really suggests code that you are about to write. Yes, there are some downfalls of it like it always suggests ‘var’ instead of ‘let ‘when you declare a variable and loops are always those older versions of loops instead of the ES6 syntaxes.
For HTML I haven't found it much useful it was trying to find the pattern in which I wrote the HTML from the same file but was not up to par.
I really wanted to highlight this point it is not just another auto-complete we have in the extensions. Whenever you write a function name it knows what you mean and tries to deliver the same output. Also, it has a context of the whole file you are working with. Let me explain to you with an example
I am using a Vue framework for this example
In the above Image, as you can see I have declared a variable in data() property called name (Array) and I was trying to write a function called addName(). It really blew my mind when it predicted the next line. It was pushing a ‘New Name’ in the same array.
Here is what is happening the GC knows the variable name and it is an array when I wrote addName() method it suggested pushing the new name in the same array. Doing this level of understanding really impressed me with what the future holds.
Every good thing comes with a side effect. The thing that is most irritating about GC is it is always predicting. Many times when you are writing code you are in a state of flow and it keeps suggesting stupid code which is irrelevant. In the editor, when the GC suggests if you hit the tab you accept the suggestion and we want tabs for spaces and formatting.
It was frustrating to always end up accepting the wrong suggestions and then use spaces to avoid them. GC is not very customizable yet in VSCode, Maybe they should have some more customization that enables some patterns or defining keyboard keys to accept or decline the suggestion.
I would say it is a very powerful tool and once you get used to it, it will be very difficult to stay without it. It is also a blessing and a curse for beginner developers as they will not know the pain of finding that perfect piece of code on the internet for hours. People are also calling it just StackOverflow in your editor but I feel it is more than that.
Broadly it is not just helping you with syntax it is learning and understanding your patterns. For now, I don't think it is going to take any jobs away because if the client wants to build a project eCommerce he will have to be very specific about the instructions given to GC. Just saying a function generateRandomNumber() will not work.
I was really scared and excited to see the Fireship video on GitHub co-pilot.