AI tools in programming
Scientific workflows: Tools and Tips 🛠️
2024-01-18
What is this lecture series?
📅 Every 3rd Thursday 🕓 4-5 p.m. 📍 Webex
- One topic from the world of scientific workflows
- Material provided online
- If you don’t want to miss a lecture
Motivation
- AI tools assist programmers with
- Coding
- Debugging
- Learning
- …
- Higher productivity and efficiency
- More motivation
Today
Focus on integrated AI tools
- How to use GitHub Copilot to
- Speed up your coding
- Improve your code
- Learn
Concerns when using AI tools
Main goal: Motivate you to try out tools and find out what fits your workflow
Find other tools on the website
Now You
❓ What is your main programming language
❓ Which IDE (programming environment) do you use
❓ Which AI tools for programming did you already try
GitHub Copilot
- Cloud-based AI tool by Github and OpenAI
- Model based on GPT-4 and OpenAI’s Codex
- Specifically trained on source code
- Basic idea: Plugin for your IDE to integrate Copilot
- Works best for well-represented languages (Python, JS, …)
How to get GitHub Copilot
See lecture website for step-by-step guide and more information.
It’s really easy, but you need:
- GitHub Account
- Active GH Copilot subscription (10$ per month)
- Get it for free as an academic with an educational account
- IDE that supports Copilot
- Full support: Visual Studio (Code), Vim, Neovim, JetBrains IDEs (e.g. PyCharm)
- Limited support: RStudio, ?
Using GitHub Copilot
Demo of the main features and use cases
Inline code suggestions
- Copilot tries to predict what you want to do next
- Suggestions are based on the context
- Previous code
- Comments
- Variable and function names
- …
Get better suggestions
- Provide context
- Open other files
- Add top level comments explaining the purpose of the script
- Name variables and functions properly
- Copy-paste sample code and delete it later
- Be consistent
- “Garbage in, garbage out”
- Have a nice and consistent coding style
Nice side effect of using Copilot: More good-practice coding
Chat
- Ask and give commands regarding:
- Highlighted lines of code
- The whole script or project
- Preset commands starting with
/
/fix
: fix problems in your code
/doc
: get documentation
/explain
: explain this code
/test
: write unit tests
/new
: create new projects or scripts with code
/fix with in-line chat
/doc with specific documentation standard
/explain