In-Depth

Mads Kristensen's Sneak Peek at Visual Studio's AI Future, To 'Rekindle Our Love of Coding'

With advanced generative AI systems reshaping software development, Microsoft's Mads Kristensen provided a sneak peek at the AI future of Visual Studio.

Speaking to a packed house at this week's Visual Studio Live! conference in Las Vegas, Kristensen in a keynote presentation detailed how AI can be put to use in the IDE "to help us rekindle our love of coding."

The principal product manager for Visual Studio used his inside insights into the dev team's work to discuss how AI could revolutionize tasks in five general areas: writing code; debugging; profiling; explaining code; and providing a starting point for projects.

While AI-powered tools like GitHub Copilot and IntelliCode have already started down that path, more advanced technology is in the works to take their capabilities much further, especially in the generative AI space. Here are some highlights of the AI portion of Kristensen's keynote.

While the aforementioned tools can generate code, there are many more opportunities to use generative AI to write code. As an interesting, related point of fact, Kristensen revealed that studies have determined the median amount of time a developer spends in actually writing code is only 52 minutes per day. Even though that's a small amount of time, for most developers actual coding is the most interesting part of the complex workflow that they undertake each day. And AI can make it even more enjoyable in many different ways, including the following:

  • Voice Assistant: As a simple example, Kristensen used a voice assistant extension he had just developed with Brady Gaster from the .NET team. "So you could say, 'Hey VS' and then it started listening, and we could give it an instruction. So we said, 'Hey VS, create a C# class called Person that has a first name and a last name and a constructor, and everything is fully documented with XML code comments.' And boom! That was it, it just wrote the code for me completely, the perfect scaffolding. And it's much quicker. Even though I can write that kind of stuff pretty quickly -- nothing compared to that."

  • Code comments: "I hate code comments. I hate writing code comments. I love reading code comments, but I hate writing code comments. So what if AI could help us with that? What if my topology of my app involves SQL Server databases, some Azure Blob Storage, a Key Vault, some services here and there, some NuGet packages, some different SDKs, and I could tell Visual Studio to help me generate code that would retrieve a list of users from the SQL database using Entity Framework and correlate that with the blob storage files that they have available? Using the Key Vault to figure out the permissions, blah, blah, blah. And it could do that whole thing. It could write it, it knows how to write against those different SDKs. How absolutely fantastic would that be?"

  • API examples: These are already being provided in an IntelliCode preview (see the Visual Studio Magazine article, "Visual Studio IntelliCode Preview Offers Instant API Code Examples"). "So when you hover over something, it can tell you how other people write code against that same NuGet package -- that same method in the same context as you are in.

    "And so the AI is able to figure out what the context is, and serve the most accurate API examples most relevant to you at that point in time in your context. We are already on our way there. So I'm absolutely fascinated by this. This is fantastic stuff."

    Mads Kristensen, Principal Product Manager, Microsoft

    "And so the AI is able to figure out what the context is, and serve the most accurate API examples most relevant to you at that point in time in your context. We are already on our way there. So I'm absolutely fascinated by this. This is fantastic stuff."

Debugging is one of those non-coding tasks that take up a lot of a developer's time, so new AI functionality to help out is especially welcome.

"We all want to be better at debugging," Kristensen said. "And if we ask people, 'What are the things you want to be better at as developers?' debugging is always in the top three. We all know, there's always that one person on the team that is just the go-to person when it comes to debugging. And they understand simple loading and modules and stack frames and multi-threaded parallel views and like WinDbg, and all this advanced stuff, and it's like, I don't even know how to begin with that.

"So what if we could have AI, even for basic examples. Like, let's say that I'm debugging, and I hit a null reference exception. Well, for most people here, that's probably trivial to know what caused that. But if you're a newer developer, or new to a language that has that concept, let's say, wouldn't it be nice if the exception that occurred while you were debugging told you what's the variable? Or what's the thing that created that, and trace it back to where it came from? What was the condition in the program that led to the null reference, and then offer your solution on how to fix it? That's a basic example, right? But you can kind of see how that would be helpful to a new person."

And, while that was a simple example, AI could be pointed to much more complicated scenarios, involving things like multi-threaded applications where call stacks are running on teach thread.

"What if, in plain English, AI could just analyze all that stuff and tell you, 'Oh, here's the issue. You are blocking the UI thread, and you're creating a deadlock, because this condition over here was set -- to fix this just go ahead and do that.' Oh, my God, that'd be fantastic, right? So we're kind of thinking of that -- we actually have some prototypes already. But early, early stages here. Another aspect that I'm very, very excited for."

Here, Kristensen discussed the little-used Visual Studio profiler.

"It gets better and better with every release. We know that you don't use it [audience laughter]. But it gets better and better with every release. And I'm like, I'm advertising for it. I use it on my extensions. It finds things that you're not even aware of was a problem. So let me just explain. So a profiler instruments your code, so it understands how it's being executed, what the values were flowing through, how long certain calls took, how much memory was used by these objects and so on. It knows a bunch of information about your running application. That's extremely valuable. It's different from from debugging."

One example of how AI could help out here is the capability to optimize a method that takes an IEnumerable that is passed in as a list data structure or other structure that's slow to loop over. AI would know a developer should change that structure to a hash set, a .NET type that could cut down the looping time and speed up the execution of the method by a factor of a thousand. AI can figure such things out and offer solutions to fix or optimize code constructs.

The same thing applies to regular expressions, or regex.

"It's like, we all have to use regular expressions sometimes. Some people hate them -- most people hate them -- some people love them. But the fact is, very few people are good at them. So how fast is a regular expression? Well, we kind of need the runtime -- at runtime -- to figure that out. But how do we know if there's a bit more optimal version of that same regular expression? Well, the AI can figure that out. So it can come in and give you these recommendations that at the end of the day, make your program faster and more reliable. And it's just plain English. Or sometimes it will fix it for you: click here to fix it. A little light bulb, or you know, those margin ones that show up in the margin, little light bulbs or quick fixes, as we call them. Great stuff, a lot of potential here."

Examples of how AI could serve developers by explaining code are bug fixing and repo cloning.

  • Bug fixing: "We're being assigned GitHub issue 483, and we're like scratching our heads. Okay, what's the next step? I got to fix this issue, but what projects in my solution does this bug belong to? And what file do I open? How do I fix this? So you kind of do a lot of spelunking around the codebase to figure out what's going on and what to edit. But what if the AI could figure that out for you? So if you just tell it, 'Hey, I want to work on 483, issue 43,' it'll just go in, 'Okay, here's the relevant files for you. Just change the this Blazor file here and some C# over there, and that should fix that issue.' Or even better, 'Click here, and I'll do it for you.' I don't know if it's better, but it's different. It might be helpful, right? At least tell you what it thinks and give you that head start, so that you're still in control, but you no longer have to spend all that time trying to understand the code. That'd be helpful."
  • Repo cloning: "What if you for the first time clone a repo, and you're trying to understand what's going on? It's a solution in there, it has like a bunch of projects, 200 projects. And you're like scratching your head, 'Oh, what do all these projects do? How do they relate to each other?' This is when we start a new job or a new contracting gig or something like that. We're trying to understand existing code. Like that's just really, really hard. So what if we can just ask the AI, say, 'Hey, give me like a TLDR. What is this project? What does that project do?'"

    And, if a developer is just interested in the iOS portion of an app, AI could explain the different projects that constitute that iOS part. "And you kind of get a personalized README file, let's say, for the things you're interested in knowing. So that will be super helpful to onboard new people to understand new code bases." Kristen explained how the same technique could also be used for smaller code constructs, even individual variables in a method, or to explain what a certain class does.

For this capability, to help developers get started on a project, Kristensen used as an example a web site for a bakery.

"There's a new bakery in town, and they want me to build their web site. So in Visual Studio, how do we go about this, we go to file, new project, MVC app. Easy, I get a generic starting point. But you know, no matter what I choose from those templates, I kind of always feel like I made the wrong choice. Sound familiar? And it's generic, it's not a bakery site. I have to do all that work. I have to turn like a generic thing into like a bakery site."

With AI helping out, Kristensen envisioned a conversation something like this:

Developer: I want to create a new project.

AI: Oh, what do you want to build today?

Developer: I want to build a web site.

AI: Okay, do you want just a web site? Or do you want a phone app or something to go along with it?

Developer: Oh, no, I just want the web site.

AI: Okay. Is it for an individual or is it for a company?

Developer: Oh, it's for a company.

AI: Okay, what kind of features do you want?

Developer: Oh, I want people to be able to buy online.

AI: All right. Tell me about the web site.

Developer: Oh, it's small bakery. You know, specializing in cupcakes and croissants. It's family owned, nice family, you know, in the heart of Las Vegas.

AI: Okay, that sounds good.

"And you click the Create button. And out comes the web site that looks like a bakery. It has pictures of croissants and cupcakes. Yeah, it has that small family owned vibe to it. All the text that's there relates to baking, it already integrated with a payment gateway like Stripe, or something like that, by getting the right NuGet packages, hooking everything up, authentication. So now all I have to do is to do all the awesome stuff, like the details, making sure it looks perfect, it's exactly to their liking. And if it wasn't really that good, if it was a little bit far from where I wanted it to be, I'll just run it again, and be more precise.

"AI could do stuff like that. So we could take all the mundane work out of hooking basic stuff up like NuGet packages, and connection strings and whatnot, and have the API give us like the ultimate starting point. I think that will be super, super cool."

On to Nashville
The AI portion of Kristensen's keynote was just one part of his presentation, "Visual Studio Secrets Uncovered," in which he detailed the behind-the-scenes workings of the Visual Studio dev team and much more. And his jam-packed session was just one part of the big Las Vegas VSLive! conference, a series that has provided developer-focused training for 30 years.

For more such valuable insights, advice, hands-on demos and workshops, the next big VSLive! show will be a five-day event in Nashville, being held May 15-19, where you can expect industry experts and Microsoft product team members to again share their knowledge and help you take your developer skills to the next level.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube