News

Exploring the 'Almost Creepy' AI Engine in Visual Studio 2022

As the GitHub Copilot "AI pair programmer" shakes up the software development space, Microsoft's Mads Kristensen reminds folks that Visual Studio's IntelliCode ain't too shabby, either.

Kristensen, known for his voluminous extension authoring for all kinds of Visual Studio functionality, today (Oct. 31) authored a blog post/video examining the IDE's AI engine as part of "Cool features in Visual Studio 2022." Visual Studio's AI engine, IntelliCode, was part of that discussion (based on a previous presentation).

Despite the advent of GitHub Copilot, Microsoft's flagship IDE continues to use IntelliCode, which is based on the same underlying AI tech, but with important differences.

GitHub Copilot burst onto the dev scene last year and in June became generally available as an editor/IDE extension available for Visual Studio Code, Visual Studio 2022, Neovim and the JetBrains suite of IDEs.

GitHub Copilot
[Click on image for larger view.] GitHub Copilot (source: GitHub).

As an "AI pair programmer," it provides advanced code-completion functionality and suggestions similar to IntelliSense/IntelliCode, though it goes beyond those Microsoft offerings thanks to Codex, the new AI system developed by Microsoft partner OpenAI. While IntelliCode is powered by a large-scale transformer model specialized for code usage (GPT-C), OpenAI Codex is an improved descendent of GPT-3 (Generative Pre-trained Transformer) that can translate natural language into code. Now more than a year in, it has boosted developer productivity while causing a negative backlash across a number of concerns.

IntelliCode, meanwhile, provides AI-assisted IntelliSense, able to predict the most likely correct method or property for a developer to use instead of just an alphabetical list, because it uses the developer's current code context and patterns to provide a dynamic list of options.

"IntelliCode saves you time by putting what you're most likely to use at the top of your completion list," says Microsoft documentation. "IntelliCode recommendations are based on thousands of open source projects on GitHub each with over 100 stars. When combined with the context of your code, the completion list is tailored to promote common practices."

The 'Starred' IntelliCode Suggestions
[Click on image for larger view.] The 'Starred' IntelliCode Suggestions (source: Microsoft).

Along with statement completion, IntelliCode supports team completions, argument completions, inferring code style and formatting conventions, and more.

In a video published today with the blog post, Kristensen explored the IntelliCode functionality, while explaining the difference between IntelliCode and GitHub Copilot.

IntelliCode in Visual Studio 2022
As noted, IntelliCode improves on IntelliSense with the ability to analyze code context and promote the code typing options most likely to be used by individual programmers depending on what they're working on. Kristensen demonstrated this capability in a simple console app where IntelliCode predicts a string named "LastName" is likely to be added by a developer constructing a Program class that starts out by declaring "FirstName."

"Notice how Visual Studio automatically will suggest that I put in a last name, which is exactly what I want in this case," Kristensen said. "I want the LastName property to be inserted for me right here. I also want the full name, so let's hit enter again, and this time it suggests "age," which could be the accurate one, but I want full name so I'm just going to pretend it's not showing me anything and just start typing 'public string FullName,' and notice here I can just hit tab and I get my full name and it understands that FullName is a product of FirstName and LastName. This is really, really fantastic.

"So the AI engine here in Visual Studio understands the context I'm in. It understands that I'm right under the FirstName property, chances are that I might want another property is relatively big, and based on the first name it then also suggests, 'hey the last name is usually what other people will add as the next logical property.' But what I was really impressed by, was the full name -- that it understands what a full name is, right. It understands that when people have a first name and a last name and they need a full name, this is what they want. Absolutely fantastic here."

Kristensen went on to demonstrate how Visual Studio's AI engine understands a coder would want an AddData method when working up a List that starts out with a RemoveData method.

"I'm going to create an AddData method, so notice that based on the name RemoveData, you know it understands what remove means and add, and so it suggests that I created a method called Add, but what was crazy was that it knew what that would do inside the method, right. So it knew that it should not take the list and remove something, it should add to that list, so this is just absolutely fantastic."

He also demonstrated the ability of IntelliCode to generate code based on natural language input. This is similar to OpenAI Codex being able to generate whole lines of code or even entire simple projects -- like a simple game -- simply by entering commands in natural English. In this case, rather than responding to typed commands, IntelliCode interprets developer desires entered as a code comment.

Turning Words into Code
[Click on image for larger view.] Turning Words into Code (source: OpenAI).

"So let's say that I want to create a new method or I want some code, but I'm not entirely sure how I should write it," he said. "What I can do is that I can express it in a code comment like this one. So here I have a comment it says, 'take the two arguments and add them together.' So the args refers to the args that come into the to the main method up here.

"So I'm just writing here in plain English what it is that I would like to have happen, and now I can hit enter and Visual Studio will automatically suggest what that code might look like. So it understands what I'm saying in English in the code comment and can translate that into something that might be what I want. So this is absolutely fantastic. So this is the AI engine that is built upon a huge data set and using machine learning. It's able to take the context that the AI engine is aware of and pair that up with the big machine learning model of what do people do in situations like this. That's basically what the machine learning model knows, and when we pair those up together, Visual Studio can do amazing things like this."

In addition to the IntelliCode AI engine in Visual Studio 2022, other cool things demoed by Kristensen include new debugging capabilities, including temporary breakpoints, using Source Link to find actual source code of third-party code, such as found in a NuGet package, and much more.

Difference Between IntelliCode and GitHub Copilot
In a similar livestreamed video last year ("Hacking Visual Studio - Visual Studio's AI engine"), Kristensen discussed the difference between IntelliCode and GitHub Copilot. Officially, an OpenAI blog post from August 2021 states: "What is the difference between GPT-3 [the tech related to IntelliCode's GPT-C] and Codex? OpenAI Codex has much of the natural language understanding of GPT-3, but it produces working code -- meaning you can issue commands in English to any piece of software with an API. OpenAI Codex empowers computers to better understand people's intent, which can empower everyone to do more with computers."

Kristensen further explored the issue in response to a developer's question during the livestream event last year, asking about the difference between IntelliCode and GitHub Copilot.

That question was answered by co-presenter Aaron Yim of the Visual Studio AI engine team. "So the GitHub Copilot team, along with the IntelliCode team, are interested in kind of the same problem space," Yim said. "Our products are completely separate, and I think the key difference here is that GitHub's Copilot runs -- requires kind of a server to inference against -- whereas IntelliCode's inline completions and suggestions -- so all of our features -- work entirely locally on your machine. So none of your code will leave your machine if you're using IntelliCode, and so this is going to work on a plane if you'd like."

Kristensen replied: "So that's a big fundamental difference in that you're 100 percent local. But the the big machine learning model and the all the training data and all this sort of stuff -- does that then ship with Visual Studio that locally Visual Studio is able to to query, or how does that work?"

"Yeah so actually this has been one of the top feature requests to have the IntelliCode model ship out of the box in Visual Studio, and so I believe this is going to happen for Visual Studio 2022," Yim said in the October 2021 video, noting that developers won't have to download the model separately at install time. He said this is especially important in high-security situations where additional extensions aren't allowed. A Microsoft site states: "IntelliCode is installed by default with any workload that supports C#, C++, TypeScript/JavaScript, or XAML in Visual Studio 2022," while recent July documentation says IntelliCode supports five languages and 13 workloads in Visual Studio 2019 version 16.4.

The differences between IntelliCode and GitHub Copilot were also discussed in a Hacker News thread in June 2021, wherein a comment from a developer who works at GitHub echoed Yim's summary: "The IntelliCode and Copilot teams have been collaborating closely together, since we want them to provide a 'better together' experience. However, the underlying tech isn't the same. Copilot is powered by OpenAI Codex, and enables rich code synthesis via a cloud service. Whereas IntelliCode uses multiple local models, to enhance various parts of the editor (e.g. prioritizing the completion list based on your context, detecting 'repeated edits' and suggesting additional refactorings)."

More discussion -- including more insights from Microsoft -- ensued on a Reddit thread some nine months ago titled "Visual Studio 2022 IntelliSense is so good it's almost creepy" [as one commenter pointed out, there's some confusion between IntelliSense and IntelliCode]. Here, one comment from "Aaron from IntelliCode team" reads: "The underlying tech between Copilot and IntelliCode is different. Copilot uses CODEX model and cloud inferencing to generate whole functions/tests at once. IntelliCode uses GPT-C model inferenced locally, will only ever generate up to a whole line of code at once."

Another comment in that thread reads: "Yep, in 2022 they added a copilot-like functionality. It shows you a code prediction and you can accept it by pressing tab. It doesn't make huge code predictions, but it predicts things like method call arguments with a respectable amount of success, for a first version at least. It makes things like manually writing a bunch of props so much faster. I used to just copy paste { get; set; } because it keeps cramping up my hands, and the prop snippet is wonky, now I just tab it off."

However, not everyone agrees that Visual Studio's AI engine is so amazing as to earn several "creepy" characterizations floating around out there, such as in the aforementioned Reddit thread. For example, one comment on that thread said: "I don't know why answers like this gets downvoted, but it's true 100 percent. IntelliSense (and Copilot) are great for boilerplate code, and that is pretty much it. Personally, I find it very useful when I need to map some objects, write simple null checks and stuff. But as soon as you start really doing the work, it's zero. Really, it's not creepy, and we are safe for at least another 50 years. You as a developers should really know that this so called AI is nothing but a bunch of almost random numbers, and their use cases are so so limited. So relax please, it's handy but not creepy."

Creepy or not, it's interesting to speculate on the future of the AI-assisted coding assistant in Visual Studio. Will it just continue to be based on IntelliCode (and GTP-C)? Will it switch to incorporate GitHub Copilot (and Codex), with external inferencing and all? Will the two technologies merge together somehow in a Visual Studio-specific hybrid offering?

Stay tuned, as time will tell.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

Subscribe on YouTube