GitHub Copilot and Coding Assistants: The Future of Development

Learn about seamless integration, navigate suggestions like a pro, and personalize your coding companion

Slalom Boston Technology Enablement
Slalom Data & AI
10 min readFeb 5, 2024

--

Photo by Christina Morillo from Pexels

By Ananya Rajagopal, Archisa Sood, Jonah Abraham, Karthik Sridhar, Trupti Sanikop, and Mohammad Ali Al-Rajjal

Ever find yourself bogged down by looking up mundane coding queries during development? (“How do I loop through this list in [language] again?” checks StackOverflow). These frequent context switches can significantly erode your time for tackling more intricate challenges.

Enter Microsoft’s GitHub Copilot, which aims to revolutionize development workflows by significantly reducing these time-consuming interruptions.

Copilot embodies an AI-powered coding assistant, leveraging the same Large Language Model (LLM) technology behind ChatGPT. Trained on vast public datasets like GitHub, it possesses a unique grasp of software development nuances. Seamlessly integrating into popular integrated development environments (IDEs) like Visual Studio and JetBrains, Copilot offers a natural language chat interface for dispensing real-time coding advice. Currently available for individual and enterprise purchase, Copilot unlocks a new era of developer productivity.

In this blog post, we’ll equip you with the knowledge and resources to seamlessly incorporate Copilot into your development workflow and experience firsthand how it can optimize your coding journey.

Getting started with GitHub Copilot

Prerequisites:

Before installing GitHub Copilot ensure you have a GitHub account and that you have signed up for GitHub Copilot through the GitHub website https://github.com/features/copilot/ and ensure select the appropriate Business or Personal plan.

Configuring your IDE:

GitHub Copilot is configured to work with an IDE. It is installed as an extension to the IDE. It is currently available for in available as in Visual Studio Code, Vim, Neovim, JetBrains IDES (like IntelliJ), and Azure Data Studio.

For the purposes of this example, we will use Visual Studio Code (VSCode) as the IDE. To install GitHub Copilot as an extension on VSCode, navigate to the extensions tab and search for the Github Copilot extension, and click on the “Install” button as shown in the image below.

GitHub Copilot Extension in VSCode

Upon installing GitHub Copilot, you will be prompted to sign-in to GitHub using the account you have configured in the first section. Follow the prompts to sign in with your GitHub account.

GitHub copilot also offers an extension called GitHub Copilot Chat, that offers a chat-based interface for developers to interact with GitHub Copilot using natural language prompts. It allows developers to ask questions and look for code suggestions and explanations in the form of a more dynamic conversation.

GithHub Copilot Chat Extension in VSCode

In addition to both GitHub Copilot and GitHub Copilot Chat, there is another extension called GitHub Copilot Labs that offers developers early access to features that developers can experiment with and provide feedback to help shape the development of these features. One of the features currently available in GitHub Copilot labs is Code Explanation, which allows developers to highlight a block of code and ask GitHub Copilot to explain it in plain words.

GitHub Copilot Labs Extension in VSCode

Once the GitHub Copilot is installed and connected to your GitHub account, you can configure GitHub Copilot settings and customize its behavior to your own preferences. These settings can be accessed by clicking on the gear icon in the GitHub Copilot tab. You can configure settings like Line Start Suggestions which controls when GitHub Copilot provides suggestions whether as soon as you start typing a few characters or when starting a new line. You can configure your Code style and tailor things like indentation and formatting to your preferences as shown in the image below.

Settings Preview for GitHub Copilot Extensions in VSCode

Collaboration, not replacement

Microsoft’s GitHub Copilot is not a silver bullet for software development — its documentation rightly clarifies that it isn’t a human replacement. Developers entering vague application descriptions and expecting magical code generation will likely be met with disappointment.

Copilot shines as an augmented coding assistant, leveraging your existing code as a springboard for improvement. Consequently, code clarity becomes paramount. Precise variable and function definitions, coupled with insightful comments, provide Copilot with the context necessary to generate relevant outputs that seamlessly integrate into your code. Avoid generalities in your requests; concrete, well-defined prompts yield more reliable results.

For instance, when developing a function to retrieve a movie list from a database, having related functions readily accessible within your editor grants Copilot valuable context for constructing the return function. Similarly, clear comments like “This function retrieves Employee IDs from the database” guide Copilot in the right direction. Consistent, intuitive variable names (e.g., “EmployeeID”) across your codebase further enhance output accuracy.

Furthermore, Copilot’s training on public datasets influences its performance across languages. Commonly used languages like Python offer more reliable integration than less ubiquitous ones like Forth. The same principle applies to the base language of your queries; English, being the dominant language in its training data, generally yields better results than others.

Copilot Labs and Chat are two extensions for GitHub Copilot that provide additional features and functionality. Although Copilot extension in itself provides capabilities, we will explore some additional use cases with these two extensions. Let’s look at different examples in which GitHub Copilot can be used.

1. Workspace setup with chat view

GitHub Copilot can significantly reduce effort and time spent creating workspace.

In this example, we are creating a directory structure for an employee application. The command “/createWorkspace Employee java application directory” suggests a directory structure and a button to create workspace if you accept.

VSCode Workspace with GitHub Copilot Chat suggesting Create Workspace

2. Code generation with natural language commands

Copilot can understand and interpret natural language commands, allowing users to interact in a conversational way.

In this example we are instructing Copilot to create a model for Employee. Copilot suggests a few options.

Natural Language Command code generation with GitHub Copilot

3. Code generation with shortcuts

To see all suggestions of Copilot at once, we can use shortcuts. In this example we are creating an interface for the Employee application.

GitHub Copilot suggestions with shortcuts

4. Boiler plate code with chat view

Copilot can generate boilerplate code for a variety of tasks, including:

  • Connecting to databases
  • Logging messages
  • Handling errors
  • Writing tests
  • Creating classes and functions

In this example, we’re asking Copilot to generate boiler plate code to connect to MySQL using JDBC.

Boiler plate code generation with GitHub Copilot Chat

5. Generating doc with inline chat

Inline chat with Copilot can be a great way to improve the quality of your Javadoc and to generate Javadoc more efficiently. In this example we are generating doc for the getEmployee function with inline chat.

JavaDoc generation With GitHub Copilot Inline Chat

6. Troubleshooting with slash commands

In this example using the inline chat capability of Copilot we are asking to explain how the code works. Notice that it points out the code is buggy and suggests a solution.

Using /fix in inline chat is a way to compare existing and suggested solution.

Troubleshooting with GitHub Copilot Slash

7. Code coverage with Labs*

Copilot Labs can generate test cases in a fraction of the time it would take to write them manually. Currently this feature is only supported for JavaScript and Typescript.

In this example we are generating a test for getAllEmployees() function written in JavaScript.

Test case generation and code coverage with GitHub Copilot Labs

8. Language conversion with Labs*

Many a times developers must look at legacy code written in language less familiar to them and it takes time to analyze. Copilot can easily translate code to a language that the developer is adept in. In this example, we are converting getEmployee function written in Java to Python.

Code Conversion with GitHub Copilot Labs

Navigating the nuances of GitHub Copilot

While GitHub Copilot promises significant potential for streamlined coding, its effective utilization requires thoughtful consideration and adherence to specific best practices. Firstly, it’s crucial to remember that Copilot operates within the confines of your project’s context. Its suggestions, grounded in the open files within your IDE, lack an innate understanding of broader business goals or user narratives. Thus, a diligent code review process, akin to verifying snippets from StackOverflow, is essential before integrating any generated code. Thoroughly examine the functionality of the proposed code to ensure seamless integration and avoid unexpected consequences.

Furthermore, it’s important to acknowledge the limitations of Copilot’s knowledge base. Particularly, its understanding of Playwright currently rests on data from 2021 and may not encompass the library’s recent advancements. To safeguard code quality and security, consider embracing robust SDLC practices such as peer reviews and automated security scans. Additionally, remember to disable Copilot in projects where its usage is restricted by specific policies or requirements.

Optimizing Copilot’s effectiveness further hinges on crafting clear and concise requests. GitHub’s guidelines encourage experimentation with varied prompts, allowing users to refine Copilot’s responses to match their specific coding needs. Maintaining relevant tabs open, offering additional context from neighboring files, and adhering to established coding practices further improve the generated code’s alignment with project standards. Ultimately, GitHub’s emphasis on well-defined prompts and contextual awareness empowers Copilot to deliver increasingly relevant and impactful suggestions.

Despite the undeniable appeal of AI-generated code, a rigorous review process remains paramount. Akin to reviewing a colleague’s work, developers should meticulously analyze the generated output, ensuring its accuracy and adherence to project requirements. By consistently applying these practices and leveraging GitHub’s prompt-writing resources, developers can unlock the full potential of Copilot, transforming it into a valuable and efficient asset within their coding arsenal.

GitHub Copilot Context

This class implements business logic. It contains various methods that performs operations related to employees. It’s using the model Employee import and implementing the EmployeeService interface. Based on this context and the relevant tabs open, just the comment “implement createEmployee” it suggests a solution.

Other code assistants

Google’s own collaboration with OpenAI has resulted in Duet AI, currently in preview. Available in Google Cloud and in IDEs via the Cloud Code extensions, it can perform code refactoring, recommendations, code completion or code generation. Duet AI also provides a variety of productivity enhancing features across all of Google’s Workspace apps, allowing you to summarize documents, create spreadsheets and presentations. It’s worth noting that the productivity feature is analogous to Microsoft Copilot, which works alongside Microsoft 365 Apps.

Amazon has come out with its own coding companion, Amazon CodeWhisperer. It supports code generation for a variety of languages like C#, Java, Python and Rust, though it is optimized for most AWS APIs, AWS Lambda or AWS S3. It additionally scans both generated and written code vulnerabilities and security risks and provides suggestions on fixes.

In addition to these general-purpose assistants, there are a large number of tools created to perform specific tasks. The Docker GenAI Stack provides best practices and recommendations to developers while modifying a DockerFile or Docker Compose file, debugging and testing container-based applications. Codium AI analyzes code, docstring and comments to suggest tests as you code. Cogram helps data scientists to generate complex SQL queries based on queries in the English language. The landscape of tools is growing rapidly.

The future of development

The future of GitHub Copilot paints a vivid picture of enhanced accuracy, context-awareness, and developer customization. Advanced machine learning will refine code suggestions, streamlining development processes, minimizing errors, and liberating developers from routine tasks. At the core of this vision lies a highly customizable tool tailored to individual workflows and preferences. This adaptability promises to unlock a more efficient and personalized coding experience, empowering developers to focus on complex challenges.

The forthcoming Copilot Workspace exemplifies this commitment to enhanced functionality. Scheduled for release in 2024, it will transcend code generation, assisting with full development tasks. Imagine: inputting an issue from a project management tool like JIRA, and Copilot Workspace extracts the code’s current behavior, proposes solutions, and even handles scaffolding tasks like setting up testing frameworks. Its comprehensive understanding of code, including comments and linked information, elevates its capabilities beyond mere suggestion.

With the anticipated arrival of GitHub Copilot X, the coding landscape is poised for further transformation. Leveraging cutting-edge machine learning, Copilot X vows to revolutionize code accuracy and context-awareness. This evolution not only aims to accelerate development but also personalize the experience. Its ability to not only grasp developer intent but also adapt to diverse coding styles and languages fosters a truly versatile tool, pushing the boundaries of human-AI collaboration. Through Copilot X, GitHub reaffirms its dedication to advancing AI in coding, paving the way for a future where developers and AI seamlessly collaborate to unlock the full potential of software development.

*Note that Labs was sunset in December 2023.

Slalom is a next-generation professional services company creating value at the intersection of business, technology, and humanity. Learn more and reach out today.

--

--

Slalom Boston Technology Enablement
Slalom Data & AI

We build products and enable organizations to move faster through application of modern technology patterns that allow them to focus on developing their core