
#Visual studio code copilot code
If you’re trying to solve a problem in JavaScript it is pretty certain that someone, somewhere writing open source code has solved it before. Sounds like a lot of files…until you compare it to other languages. At the time of writing there are fewer than 100 GitHub repos containing AL code and approximately 31K AL files ( see here). Yes, it is – but that is a few H 20 molecules in a drop in GitHub’s ocean. The suggestions do improve if you give it more context and write blocks of code which are similar to something you’ve written before, but ultimately the model hasn’t been trained on enough AL code.īut wait? Isn’t the whole of the base app for the past few versions on GitHub now? That’s thousands of AL files. What’s the problem then? Why does Copilot keep suggesting code that doesn’t compile? The biggest problem is that Copilot just hasn’t seen enough AL to know what it should look like. Copilot quickly starts suggesting those lines, even with appropriate comments in calls to Assert.AreEqual(). I typically always start an automated test with Init() and finish with one or more calls to the Assert codeunit. That said, it does demonstrate that Copilot “learns” from the code that you’ve already written and can make repetitive work more efficient. We can already do that in VS Code in a few keystrokes – much faster than messing around with Copilot. I’m not knocking it – but all it is actually doing is copying the above test and replacing all instances of “order” with “invoice”. Not only do all of the suggestions compile, but they are correct. Writing an automated test with CopilotĬopilot has a much better time of suggesting the code this time, following the pattern of the above automated test. I’m going to create another test to check the same behaviour for sales invoices. Notice that I already have a test to check that releasing a sales order without a certain field populated throws an error. The below example is of writing an automated test. Perhaps an example where we provide more context is fairer. Any examples that you are going to be impressed by are likely to be written in JavaScript, Ruby or Python, not AL. Enter a method name, type a short comment that describes what the code should do and Copilot automagically suggests an implementation for your method. Those are the sorts of examples that you’ll find in YouTube videos which are enthusiastic about Copilot. Some of the suggestions use keywords from other languages: this, var and new. That’s the only other code in the file, so Copilot seems to be giving a lot of weight to that in the suggestions. Most of the solutions attempt to do something with the Order Origin Code field. CreateSalesOrder exampleĪ couple of interesting things to notice here. Let’s create a new CreateSalesOrder method and view the suggested solutions. Given that I’ve called the new method ValidateEmailAddress the extension has generated (apparently generated and not just straight copied from an existing repo) the suggested code which I have accepted by pressing TAB each time. We’ll ignore the obvious issues with the suggestions for now and just show it as an example of how the extension works.

Some Examplesīelow is an example where I have created a new procedure called ValdiateEmailAddress. Alternatively you can load the top 10 suggestions and select the best one to insert into your code. The best suggestion shows up faintly beyond the cursor and you can tab to accept the suggestion. The Copilot VS Code extension takes your existing code and comments, feeds that to the model and attempts to predict what you might want to type next. They have used that code to train an AI model. GitHub clearly have an enormous amount of open source code under their control for all manner of programming languages. I won’t pretend to know much about the inner workings of the extension but this is how I understand it.

Ĭopilot is a service from GitHub, accessed through a Visual Studio Code extension which provides suggests for code and comments as you are typing. With GitHub Copilot, get suggestions for whole lines or entire functions right inside your editor. What is it, how does it work, what’s good, what’s not so good? What is GitHub Copilot?

I’ve used it for a few weeks, tweeted enthusiastically in the first couple of days’ use and have now disabled it. For now this is necessarily a simple, first impressions post about GitHub Copilot.
