The State of IDE AI Assistants

AI is everywhere - including Integrated Development Environments (IDEs), the code editors that developers use to create software. So, what does this mean to the average programmer - is it friend or foe, help or hindrance? Let's take a look...

05-03-2024
Bcorp Logo


A bit like ‘love’ in the Wet Wet Wet song, AI seems to be all around us now.

It's getting used for everything from making music; visual arts; as a production effect in movies to de-age people (hmm, I could probably do with a bit of that myself); for data analysis and for the creation of fake videos (often controversially so). It even pops up on eBay to help with descriptions of what is for sale!

However, it is also making an appearance within Integrated Development Environments (IDEs) – the code editors that developers use to create software. So, what does this mean to the average programmer - is it friend or foe, help or hindrance?

In this blog we will attempt to address these questions and consider the current state of the art within commonly used tooling.

The State of IDE AI Assistants


In The Beginning

During 2022 and 2023 many people including students and professional developers alike (and myself) discovered the potential of using a Generative AI System, such as ChatGPT to create code snippets, answer technical questions, explain code or detect issues in code.

A Generative AI system is a software system that uses AI techniques to create internal data models from past examples to create new data, in response to new requests, that have similar characteristics. Systems such as ChatGPT developed by OpenAI utilise a LLM (Large Language Model) which is a language model that can achieve very good general purpose natural processing and generation. This allows these AI systems to interact with a user in a very human way to answer potential complex questions which can be formed as a part of an ongoing dialog.

For example, using ChatGPT, it is possible to have a dialog related to a programming problem that can proceed through a series of questions and / or prompts. The following illustrates this idea.

Human:

How can I create a number guess game in Python

ChatGPT:

You can create a simple number guessing game in Python using a while loop and some conditional statements. Here's a basic example:

The State of IDE AI Assistants


This code defines a function guess_number() that generates a random number between 1 and 100 and asks the user to guess the number. It then compares the user's guess with the secret number and provides feedback. The game continues until the user guesses the correct number.

Human:

OK but I need it to be more Object Oriented

ChapGPT:

Sure, we can make the game more object-oriented by creating a NumberGuessGame class. Here's how you can do it:


The State of IDE AI Assistants


In this version, we have a NumberGuessGame class that encapsulates the game logic. The __init__ method initializes the secret number and the number of attempts. The play method starts the game loop, and the get_guess method handles getting a valid guess from the user. The game continues until the user guesses the correct number.

I could continue by asking it to keep a record of the number of guesses made and to limit the available guesses to 4. We could also ask ChatGPT to include a cheat mode so that if the user enters the value -1 then the number to guess is displayed. The end result is:

The State of IDE AI Assistants


Note that the human can now merely select ‘Copy code’ to copy all this code and put it into their favourite IDE or a file and run the code.

The end result is not far off what I might expect a student to produce as the result of a simple lab exercise or test task – which of course has some interesting implications for educators.

However, this early approach of copy / paste could be awkward and inefficient for real world applications and developers. It also tended to require a manual intervention to allow the generated code to be integrated into an existing application.

IDE Integration

Several IDE providers have attempted to integrate Generative AI systems into their toolsets to improve the Developers workflow and make the whole process of benefiting from these AI systems more efficient and more natural.

But what does this mean? How can a Generative AI system be integrated into an IDE? Well, there are several ways in which this integration could be done including:

  • AI Prompts
  • AI Documentation
  • AI Code Analysis
  • AI Refactoring
  • AI Code Intentions
  • AI Narratives / Chat

Typically, the inclusion of one or more of these features results in the IDE vendor describing the integration as providing an AI Assistant.

Each of these will be briefly discussed below:

AI Prompts

At this level of integration, when the user performs some action, some additional prompt might be provided by an AI system. For example, if the user wanted to rename some element of the program such as a function, variable, method or class, then an AI system could be used to suggest a new name based on the context of the declaration such as its usage, location or content.

AI Documentation

Programmers typically do not like writing documentation. This is true whether we are talking about code level comments, class comments, usage guides, maintenance documentation or even commit messages. An AI Assistant can be used to generate the required documentation. To some extent simple template-based versions of such documentation generation already exist in many tools. These generation tools tend to provide a template that can then be filled in by the developer. For example, for a function or a method they might generation a template for the parameters and the return value. The AI version will also attempt to generation the actual documentation text for you. Alternatively for a commit message an AI Assistant can generate a commit message the describe the changes such as the functions, methods, parameters etc. that have been added and their purpose.

AI Code Analysis

Many / most IDEs already include code analysis features that will highlight issues in your code base such as known poor style, known buggy code patterns or non-standard programming styles or the lack of adherence to standard coding conventions. However, an AI Assistant can potentially go further by identifying less obvious or more convoluted issues. They may potentially also be able to highlight fixes or refactorings to resolve these issues.

AI Refactoring

An Ai Assistant can propose potential code refactoring based on analysis of the existing code base. It can do this by looking for Code Smells or Anti-Patterns and suggesting appropriate actions. This might be to invoke by a user action – such as ‘Find Refactorings’ or in the background with a prompt displayed unobtrusively within the editor.

The State of IDE AI Assistants


AI Code Intentions

Another approach is that an AI Assistant could allow a developer to indicate their intentions and then the AI Assistant could generate code to meet those intentions. One simple example could be an intention to ‘replace deprecated code’. If the user places such an intention within an editor, then the Ai Assistant could look for deprecation warnings and find replacements.

Some ‘Code Intentions’ might be quite simple while others might require significant refactoring (building on the AI Refactoring) facility). An Intention could be provided via a menu option, an interactive chat session or using some in file meta command such as ‘:::Replace Deprecations’. Another example of a code intention might be one to indicate that a function or method is needed that can implement some algorithm or calculation. For example, a developer might state that a function should eb created to generate a Monte Carlo simulation or to match a UK VAT number etc.

AI Narratives / Chat

The holy grail of AI Assistants is one in which a chat or narrative such as that illustrated earlier takes place within the IDE and within which the AI Assistant can take into account the existing code base. In such a scenario the developer would interact with the AI Assistant in a similar manner to another developer, discussing their requirements and constraints and examining the resulting changes to the original code; accepting or rejecting these changes as they proceed.

Current State of the AI Assistant IDE World

So given the above discussion where do things stand and what IDEs are there that either allow or exploit AI Assistants.

There are in fact several well-known IDEs with AI Assistant integration and related technologies, the most popular of which are:

Other tools to look at include:

As an example, we will look at JetBrains AI Assistant. This is generally available with the paid for versions of the JetBrains IDEs such as IntelliJ (as of the end of 2023) and Resharper. However, it also requires a JetBrains AI Server subscription. The aim of JetBrains is to enable the integration of an AI Assistant into their core IDEs in such a way as for it to be almost subliminal and to support rather than interfere with the developer’s usual workflow. How far they succeed will I suspect come clear over time. Some of the integration feels more like the existing tool’s ability to suggest and prompt – but on steroids; others such as the AI Chat interactions may feel less natural.

In general, the JetBrains AI Assistant supports:

  • AI Refactoring
  • AI Code Completion and Name generation
  • AI Documentation and Commit Message generation
  • AI Chat

The AI Assistant within the IDE is currently powered by a remote AI Server which is built on top of OpenAI’s systems (as is ChatGPT) augmented with JetBrains own models. They are also working on integrating Googles Codey and Vertex AI.

The AI Code completion and name generation is very smoothly integrated into the tool. As is the documentation and commit message generation – whether you consider the results better than what you yourself would right is another matter. However, as many developers will avoid writing documentation / comments and tend to put in minimal test to their commit messages the results generate may well be better than the (human) alternative.

The AI Assistant window allows for a chat similar in nature to the ChatGPT example presented earlier. However, currently there seems to be little evidence of full integration with the existing codebase other than some limited understanding of names and structures – this will probably improve over time with future releases.

However, you can select an existing block of code and ask the Ai Assistant to analyse it – such as to provide an explanation of that code.

Legal Position

There is another aspect to all this Generative AI technology that must be considered with respect to AI in the IDE – copyright! Just as artists and musicians are currently exploring the legal position with regard to AI generated Art and Music created using systems taught with their human original content – the use of AI with software development must consider the legal, ethical and commercial aspects of software created using AI. What is the copyright position of the code used to teach these systems or of the code generated by these systems? Who is legal responsible for that code? Even if legal such systems are acceptable is it ethical?

It is also not just an issue of copyright but also of liability. If a software system turns out to have a security flaw or some other significant bug in it that has significant consequences for the users of that system – who is responsible? Is the supplier of the final software responsible (probably but what about the Ai system that generated that buggy code – can the development organisation who may have paid for that AI service claim against the Ai system and the code it generated?)

We already know of software development organisation who, for the time being, do not allow their developers to directly use code generated by an AI system in their applications.

In addition, for the code to be analysed by the AI Assistant it is often sent off to a server to be processed with the results sent back to the developers IDE. This means that the organisations codebase is at least being sent over the network and held at least temporally on a remote server potentially outside of their organisation. This may well be against the organisation’s rules (or their final clients wishes). It may also represent a potential security risk.

Summary

This is an area that is moving very quickly and will likely improve very rapidly through 2024 and 2025. It is already making a contribution – although from a legal perspective there are still many questions to be answered.



Would you like to know more?

Take a look at our prompt engineering training course or AIOps training course

    Share this post on:

    We would love to hear from you

    Get in touch

    or call us on 020 3137 3920

    Get in touch