At this year’s Microsoft Ignite conference, everyone’s favorite developer advocate, Microsoft VP of Developer Community Scott Hanselman, took to the stage for a session titled “GitHub Copilot and AI for Developers: Potential and Pitfalls”. This session immediately caught my attention as a “can’t-miss” event because, amid all the fanfare and the promise of AI revolutionizing our working lives, it’s crucial to acknowledge and consider the downsides and limitations. I think it’s equally as important to highlight these pitfalls as it is the seemingly limitless potential of AI, so as to ground our use of it in practical applications without blindingly trusting it to make decisions on our behalf. This session demonstrated real world examples of not only how developers can leverage cutting-edge OpenAI models to enhance their productivity, but also how to establish boundaries for the AI assistant, provide it essential context, and integrate vetting its recommendations into your developer workflow.
As the tech landscape evolves, developers find themselves at a crossroads where artificial intelligence (AI) tools like GitHub Copilot promise to transform their workflows. In this how-to guide, we’ll explore the potential of AI tools for software development and the pitfalls developers should be aware of.
1. GitHub Copilot: The AI Co-Pilot for Developers
What is GitHub Copilot?
The Promise of GitHub Copilot:
- Efficiency Boost: Copilot automates repetitive tasks such as function or interface scaffolding (also known as boilerplate) allowing developers to focus on higher-value activities like implementing complex business logic and integrating external systems.
- Quality Improvements: Copilot suggests optimized code completions, enhancing overall code quality. It can also help with debugging existing code and explaining complex snippets or functions in plain English.
- Innovation: Developers can explore novel approaches using AI-generated solutions and iterate quickly over multiple implementations to find the most efficient path.
- Personalization: Copilot tailors code suggestions to individual preferences, and grounds its code style in the context of your existing codebase. This means variable names, indentation, and error message formats will be consistent with the code you’ve already written.
- Access Copilot Chat in VS Code: GitHub Copilot Chat allows you to communicate directly with a developer-tuned large language model (LLM) to ask code-related questions, get advice on how to run terminal commands, and explain code using solutions from online documentation and forums.
2. The Pitfalls to Watch Out For:
1. Context Dependency
- Copilot requires context to generate accurate code. This context comes from the code you’ve already written, or code you’ve imported into your project. The more context you provide, the better the results. However, it won’t autocomplete entire lines, so developers must still review and correct the generated code. This is especially true when working with custom classes, functions, or data models, as Copilot needs an understanding of these entities to implement them correctly in its recommendations.
2. Lack of Midline Code Completion
- Unlike traditional autocomplete tools such as Microsoft IntelliSense, Copilot doesn’t complete code as you type. You’ll need to type entire lines and then rely on Copilot’s suggestions. However, Copilot can generate multiple suggestions for a single line, leaving the ultimate decision in the hands of the developer, who can choose the correct solution for the problem.
3. No Local Model Execution
- Copilot’s AI models cannot run locally. If you prefer coding offline or need to keep your code local for compliance reasons, Copilot may not be suitable. Any code or libraries used as context for Copilots recommendations must be analyzed by its search indexer.
4. Inability to Generate Complex Solutions
- Copilot excels at generating lines, interfaces, blocks, and functions of code. But like any AI tool, it makes mistakes, and those mistakes (if not reviewed and corrected by a human developer) will lead to more future mistakes as Copilot uses its previously generated code to inform future generations. When left to generate entire solutions on its own, Copilot’s code recommendations often become scattered, disjointed, and downright incorrect.
3. Best Practices for Using GitHub Copilot:
1. Start Small and Experiment
- Begin with small projects to understand Copilot’s impact. Start with using it to enhance the functionality of existing projects, where you can easily determine if the recommendations are accurate and useful.
- Learn from failures and iterate. Copilot’s Chat interface can be used to refine solutions based on additional requirements or areas that you’ve identified need correction.
2. Collaborate Across Disciplines
- Work closely with data scientists, domain experts, and business stakeholders.
- Holistic solutions require diverse perspectives, and this is even truer when implementing AI-generated code in your application, as the AI is not without its own perspectives and implicit biases.
3. Stay Informed
- Keep up with AI trends, read research papers, and stay curious! We are at the outset of generative AI and its integration into our lives, so staying abreast of emerging technologies and how to best leverage them will keep you on the forefront of productivity.
- Understand the evolving threat landscape and how to use AI securely, safely, and responsibly.
4. Balance Innovation with Pragmatism
- Not every problem needs an AI solution. What got you to where you are today in your developer journey was your passion and problem solving. Don’t let AI get in the way of that, trust your instincts and allow AI to be just another voice in the room.
- Evaluate return on investment (ROI) and feasibility before diving in. Endlessly prompting, refining, and correcting AI suggestions for a simple-to-moderate problem can waste more time than it saves.
Remember, GitHub Copilot is a powerful ally, but it’s essential to navigate its limitations and use it judiciously. By embracing AI tools while staying grounded, developers can chart a course toward more efficient and innovative coding practices. If you’d like to learn more about GitHub Copilot and how AI can enhance your development or IT operations team’s productivity, send me a message on LinkedIn! 🚀🤖