Introduction to AI-Paired programming | MAGES Institute
diploma in games art

Introduction to AI-Paired programming

24 February, 2024

Join us for a brief overview of AI-Paired Programming, its applications and considerations, and how to get started via tools such as Github’s Copilot.

The software development landscape is teeming with new languages, toolsets, and libraries, making it challenging to pivot to different options.

As developers venture into unfamiliar territory, they typically have one of two options: borrowing code from sites like StackOverflow or pair-programing with a more knowledgeable or experienced colleague. 

Enter Generative-AI

A third option is now unlocked in the age of generative AI – AI-Paired Programming, which can not only solve your programming doubts/problems but also suggest/write some of the code itself. 

Brief History

The large-scale use of machine learning across various fields for similar purposes (such as image recognition, speech-to-text, etc) has built a common platform giving rise to Generative AI.

One such AI-assisted programming tool is Github’s Copilot, launched in 2021. As the current frontrunner, it has the advantage of having had more time and code upon which to base its decisions and feedback.

Benefits of AI-Paired Programming:

  • Innovative Problem-Solving: AI can introduce novel solutions to programming challenges that developers may not have considered.
  • Efficiency and Speed: AI-generated code suggestions can significantly speed up the development process and reduce manual coding effort.
  • Learning and Development: Offers junior developers exposure to diverse coding approaches and algorithms, enhancing their learning curve.
  • Insight into Best Practices: By analyzing a vast codebase, AI tools provide insights into current industry standards and best practices.
  • Collaborative Enhancement: Acts as a virtual collaborator, offering suggestions and improvements that complement the human developer’s skills.

Risks of AI-Paired Programming:

  • Dependence on Outdated Practices: AI’s reliance on historical data could promote the use of outdated libraries and practices, posing security risks.
  • Code Originality and Privacy: Utilizing AI suggestions may inadvertently incorporate others’ code into your projects, raising concerns over code originality and privacy.
  • Over-reliance on AI: Developers might become too dependent on AI for solutions, potentially undermining their problem-solving skills.
  • Potential for Errors: AI-generated code isn’t foolproof and can introduce errors or inefficiencies that require human oversight.
  • Ethical and Legal Implications: The use of AI in coding raises ethical questions about the ownership of AI-generated code and legal implications regarding its use in proprietary software.
  • Security Vulnerabilities: The AI’s suggestions might not always consider the latest security vulnerabilities, leading to potential exploits if not properly reviewed.

So How Do I Get Started? 

The process for installing/using Github Copilot is fairly straightforward. For this example we’ll be using Visual Studio Code as an IDE example : 

Step 1 : Open VSCode

Step 2 : Click on “Extensions” in the side bar (or use the shortcut Ctrl+Shift+X on Windows/Linux or Cmd+Shift+X on macOS)

How to install GitHub Copilot Extension in VS Code Software Development Tool - Step 1

Step 3 : Search for Github Copilot and click “Install”

Navigating to Github's Copilot Extension in VSCode Software Development Tool

Step 4 : Restart VSCode to begin using Github Copilot.

Some Examples

Generating Code Templates

Copilot can generate code templates given a prompt. Here’s an example of a python script template being created by Copilot when supplied with a well-defined prompt :

Generating Code Templates via GitHub Copilot in VSCode Software Development Tool
Generating Code Templates via GitHub Copilot in VSCode

Code Debugging

Begin with selecting/highlighting the output, and select “Copilot: Explain This”

Code Debugging via Copilot's "Explain This" feature implemented in VSCode Software Development Tool
Code Debugging via Copilot’s “Explain This” feature

This will generate an output from Copilot explaining the error :

Explanation Provided of supplied code for debugging in VSCode Software Development Tool
Explanation provided of supplied code

Code Review

Copilot can also perform Code Reviews and provide a general view of the selected code, as shown below :

 

To Conclude

AI-Paired Programming represents a significant advancement in the field of software development, offering unparalleled opportunities for efficiency, learning, and innovation. While it introduces a new paradigm in coding practices, it also brings to the forefront important considerations regarding dependence, code originality, ethical use, and security. The key to maximizing the benefits of AI-Paired Programming lies in a balanced approach that leverages AI’s capabilities while ensuring meticulous human oversight. As the technology evolves, so too will the strategies for integrating AI into development workflows, promising an exciting future for developers across the software development industry such as web development, games, augmented and virtual reality, and more. By staying informed and cautious, the development community can navigate the challenges and reap the substantial rewards that AI-Paired Programming has to offer.

    Mages Whatsup