Re-imagining developer productivity with AI-assisted tools

Amanda Silver

TL;DR:

Harnessing the wisdom of the community, Visual Studio IntelliCode is revolutionizing developer productivity. We started with AI-assisted IntelliSense and are now expanding the application of artificial intelligence to significantly accelerate learning, radically improve development agility, and increase code quality by means of two exciting new capabilities: whole line completions and refactoring.

Technology is evolving so fast that every developer is constantly learning, whether you’re adopting a new programming language, API, or architecture (e.g. microservices). Amidst this rate of technological change, existing tools are no longer sufficient for achieving agility as development teams are trying to accelerate their time-to-market  and increase code quality. As a result, development tools need to radically evolve to satisfy the productivity demands of modern teams.

At Microsoft Ignite, we showed a vision of how AI can be applied to developer tools. After talking with thousands of developers over the last couple years, we found that the most highly effective assistance can only come from one source: the collective knowledge of the open source, GitHub community. This is exactly what IntelliCode provides.

AI-assisted suggestions + whole-line code completions

IntelliCode now provides whole-line code completion suggestions mined from the collective intelligence of your trusted developer knowledge bases. This is like having an AI-developer pair-programming with you, providing meaningful, suggestions and whole-line code completions without disrupting your flow. To generate accurate suggestions and provide completion assistance as you code, IntelliCode extends the GPT-2 transformer language model for our machine-learning models to learn about programming languages and coding patterns.

The GPT model architecture, originally developed by OpenAI, has demonstrated strong natural language understanding, including the ability to generate conditional synthetic text examples without needing domain-specific training datasets. For our initial language-specific base models, we adopted an unsupervised learning approach that learns from over 3000 top GitHub repositories. Our base model extracts statistical coding patterns and learns the intricacies of programming languages from GitHub repos to assist developers in their coding. Based on code context, as you type, IntelliCode uses that semantic information and sourced patterns to predict the most likely completion in-line with your code.

Suggested whole-line completions in Visual Studio Code editor
AI-assisted whole-line completions in Visual Studio Code editor

 

IntelliCode has now extended our machine-learning model training capabilities beyond the initial base model to enable your  teams to train their own team completions. Team completions are useful if your development team uses internal utility and base class libraries or domain-specific libraries that aren’t commonly used in open-source GitHub repositories. If you’re using code that isn’t in that set of GitHub repos, those recommendations aren’t as useful to you. By training on your team’s code, IntelliCode learns patterns from your code to make more accurate suggestions. This enables your  team to accelerate  learning and take advantage of the knowledge of your team and broader community.

AI-assisted Refactoring

IntelliCode watches code changes as they occur in the IDE and locally synthesizes, on demand, edit scripts from any set of repetitive pattern changes. It uses these edit scripts to produce suggestions, enabling you to apply repetitive changes quickly or create a pull request to apply the suggestion(s) for team review without distracting your current work. IntelliCode refactorings take the time-intensity and error-proneness out of routine tasks, such as introducing a new helper function. To do so, IntelliCode uses an AI technology called program synthesis, and more specifically, programming-by-examples (PBE).

Quick action menu in Visual Studio IDE showing available actions for IntelliCode refactorings. Available actions are take the repeated edit, ignore the suggestion, or submit a new PR with the suggestion.
IntelliCode refactorings based on repetitive code edits in Visual Studio IDE

 

PBE technology has been developed at Microsoft by the PROSE team and has been applied to various products to enable users to streamline repetitive tasks after providing a few examples. You’ve seen PBE in action in Flash Fill in Excel and webpage table extraction in PowerBI. IntelliCode advances the state-of-the-art in PBE by allowing patterns to be learned from noisy traces as opposed to explicitly provided examples, without any additional steps on your part. You can read more about this in this earlier post. We’re planning to broaden this capability to more languages, as well as enabling your team easily benefit from the patterns that you find.

 

Display of IntelliCode refactoring suggestions in Visual Studio IDE
IntelliCode refactorings in Visual Studio IDE

 

What about privacy and code security?

We know that your code is a vital business asset, so we are committed to a simple principle across our developer tools and services: your code remains your code, your models are your models, and remain your models unless you choose to share them with others. You control when to utilize AI-assistance and who has access to your data.

As examples of this principle in action, when we train a team model for IntelliCode completions on your codebase, we don’t share that model with anyone but you unless you choose to share it, and we locally extract only those elements of the code that are needed to create a model for recommending completion values. We also make it easy for you to ensure that access to your model follows the same security access rules as your code repo when shared, with no extra configuration. You can read more about this in the documentation.

Our PROSE-based models work entirely locally, so your code never leaves your machine.

When it is necessary for us to use a service-based model to deliver a feature, we ensure all appropriate security is in place to secure any information (including code) that is transmitted over the network – the documentation has more information.

What’s next? 

Our ambition is to contribute to developer-assistance across the whole developer lifecycle. We’re particularly interested in making learning and retrieving typical code snippets whilst learning a new API or re-learning an old one, a lot easier. We continue to listen hard to our developer community about where we can best contribute to assist with your daily development challenges.

Get the latest Visual Studio 2019 previews; there, you can try much of this out for C# already. Watch the Visual Studio blog for more announcements as we make progress.

You can also sign up for regular updates and invitations to future private previews.

Try it now

You can try out IntelliCode team models and refactorings in Visual Studio for C# by downloading our latest Visual Studio Preview.

We also support a variety of languages in Visual Studio and Visual Studio Code:

  • Visual Studio: C#, C++, JS/TS, XAML
  • Visual Studio Code: Python, JS/TS, Java, SQL

 

Happy coding!