Programming with LLMs

Time to Pair up

Alex van Vorstenbosch

2026-02-01

What is Github Copilot

  • an LLM-Powered Code Assistant
  • Developed by GitHub, OpenAI and Microsoft
  • Helps write code faster with AI suggestions

How Does It Work?

  • Based on a GPT-model
    • Originally Codex
  • Trained on billions of lines of public (and private) code
  • Provides context-aware code completion suggestions

Supported Languages:

  • R
  • Python
  • JavaScript
  • SQL
  • Typescript,
  • C#,
  • C++
  • Ruby, Go, Rust, etc…
  • Quality of suggestions relates directly to language popularity on Github

Benefits of Using GitHub Copilot

  • Increase Productivity
  • Reduces time spent on boilerplate code
  • Helps you focus on logic rather than syntax

Learning Tool

  • Offers code examples and patterns
  • Assists in learning new libraries and functions
  • Suggests alternative approaches
  • Inspires creative solutions

Types of tasks Copilot can help with

  • Writing code
  • Translation between code-languages
  • Writing boilerplate-code
  • Documenting code
  • Writing unittests
  • Explainig code
  • Improving/Optimising code
  • Debugging code
  • Reviewing code

Limitations and Considerations

  • Suggestions can be far from optimal
    • They can also be flat out wrong!
    • Sometimes ‘hallucinates’ non-existing functions.
  • be mindfull of inconsistent use of libraries and style
    • Less so when using integrated tools like github copilot
    • More so when using seperate tools like ChatGPT or local LLMs

Remedy:

  • Always review and test the code!
  • Never just accept blindly
  • Try to understand what is going on

Security Risks

  • May produce insecure code
    • Especially when you are more on the product development side of things
  • Be cautious with sensitive information
    • Your environment can contain propriatery code or data
    • Never install copilot without consulting with your Security departement.

Intellectual Property

  • Be aware of licensing issues
  • Generated code may resemble existing code

Comment-Based Prompts

  • Write a comment describing desired code
  • Copilot generates the code for you as ghost code (press tab to accept) Example: Calculating Mean
# Function to calculate mean of a vector

Comment-Based Prompts

  • Write a comment describing desired code
  • Copilot generates the code for you Example: Calculating Mean
# Function to calculate mean of a vector
def <- function(x) {
    mean <- sum(x) / length(x)
    return(mean)
}

Asking Questions in Comments

  • Use Natural Language
  • Pose questions in comments
  • Only works for short questions
  • preferably, but not limited to, coding questions
# Q: What is a recursive function?

Asking Questions in Comments

  • Use Natural Language
  • Pose questions in comments
  • Only works for short questions
  • preferably, but not limited to, coding questions
# Q: What is a recursive function?
# A: A recursive function is a function that calls itself within its definition. This allows the function to repeat its operation on a smaller or simpler version of the input untill a base case is reached, at which point the function returns a final result.

Autocomplete Inside Projects

  • Context-Aware Suggestions
  • Considers variables and functions in your project
  • Tailors suggestions to your codebase

Example: using R-projects:

  • If you have a process_data() function
  • Copilot may suggest how to use it elsewhere

In VSCode:

  • Copilot looks at your active file and open tabs as context for suggestions
  • To a degree, this helps to keep consistency in your codebase

Demo: GitHub Copilot in RStudio

Demo

GitHub Copilot in VSCode

GitHub Copilot in VSCode

What’s Different in VSCode?

  • More extensive extension ecosystem
  • Supports Copilot Chat
    • We will discuss this in the next part
  • Multiple Suggestions
  • Press Ctrl + Enter to view alternatives

Best Practices with GitHub Copilot

  • Always Review Code
  • Don’t blindly accept suggestions
  • Ensure code meets your standards
  • Take your time to see what is happening, or you won’t learn to code yourself!
  • Learn new patterns and practices
  • Avoid Over-Reliance
  • Use Copilot to enhance, not replace, your work
  • Continue to write code independently

Pair-programming with LLM-Chats

What can LLMs mean for you?

  • How does using LLM chat differ from github copilot?
    • General purpose versus only code specific
    • More interactive
    • Longer conversations
    • Ability to guide more in the Context
    • But also more removed from IDE
    • Cannot see code context from your project

Writing code with LLMs

“What I love is that it will come out of left field with methods I didn’t even know existed. Of course in some cases those methods actually don’t exist…”

  • AdventOfCode
  • Example of a task where there reasoning models feels like a big leap forwards:
    • Can handle more complex code involving more distinct reasoning steps to solve

Writing code - SQL queries

Writing code - Regex patterns

Writing code - Pong in Python

Translation between code-languages

  • Remember this function from the exercises :)

Documenting code

Explaining code

Improving/Optimising/Reviewing code