June 2021, GitHub released a new tool.
It was called Copilot—an AI programming assistant.
You write a comment in your editor:
# Calculate the number of days between two datesCopilot automatically generates code:
from datetime import date
def days_between(date1, date2):
return abs((date2 - date1).days)You write a function signature:
def quicksort(arr):Copilot automatically completes the entire function:
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)Programmers were stunned: AI can really write code.
What is Copilot?#
Copilot is a product developed by GitHub in partnership with OpenAI.
It’s based on OpenAI Codex—a code version of GPT-3, trained on open-source code from GitHub.
Copilot integrates into editors (VS Code, Neovim, JetBrains, etc.) and automatically provides suggestions while you write code.
It can:
- Generate code from comments
- Complete function bodies from function signatures
- Suggest next lines based on context
- Generate test code
- Explain code
- Refactor code
Copilot is like a “co-pilot” helping you write code.
Copilot’s Impact#
Copilot changed how programmers work:
Improved efficiency
Programmers no longer need to write every line of code from scratch. Copilot can generate boilerplate code, common functions, and test cases.
Some estimate Copilot can reduce 30-50% of coding time.
Lowered barrier
Beginners can use Copilot to learn programming. Write a comment, see Copilot generate code, learn programming patterns.
Copilot helps beginners cross the gap between “knowing what to do but not how to write it.”
Changed role
Programmers’ role shifted from “writing code” to “reviewing code.”
You no longer write code line by line; instead, you write intent, let Copilot generate, then review and modify.
Sparked discussion
Copilot also sparked controversy:
- Copilot was trained on open-source code—does this violate copyright?
- Who owns the copyright of code Copilot generates?
- Will programmers be replaced by AI?
After Copilot#
After Copilot, more AI programming tools appeared:
GitHub Copilot X (2023)
Extended Copilot’s capabilities:
- Conversational programming: Describe requirements in natural language
- Code explanation: Explain what code does
- Test generation: Automatically generate test cases
- PR review: Review code changes
Cursor (2023)
An AI-first editor, deeply integrated with AI capabilities.
Can edit code using natural language, have AI refactor, debug, and explain.
Amazon CodeWhisperer (2022)
Amazon’s AI programming assistant, similar to Copilot.
Google Codey (2023)
Google’s AI programming assistant, integrated into Google Cloud.
Tabnine
AI code completion tool, supporting multiple languages and editors.
Sourcegraph Cody
AI programming assistant that can search and understand codebases.
Advantages of AI Programming#
Advantages of AI programming:
Efficiency boost
AI can quickly generate code, reducing repetitive work.
Accelerated learning
Beginners can learn programming through AI-generated code.
Creative stimulation
AI can provide different implementation approaches, stimulating programmers’ ideas.
Error reduction
AI can detect errors and suggest fixes.
Limitations of AI Programming#
AI programming also has limitations:
Code quality
AI-generated code isn’t necessarily optimal. May have efficiency and security issues.
Understanding depth
Programmers need to understand AI-generated code. Blind use can lead to problems.
Debugging difficulty
If AI-generated code has bugs, it may be harder to debug.
Over-reliance
Over-relying on AI may weaken programmers’ independent thinking ability.
Copyright issues
AI was trained on open-source code; generated code may involve copyright issues.
The Future of Programmers#
Will AI replace programmers?
Most people think: It won’t replace, but it will change.
AI is good at:
- Generating boilerplate code
- Completing common functions
- Writing test cases
- Explaining code
Humans are good at:
- Understanding requirements
- Designing architecture
- Making trade-offs
- Creative thinking
Future programmers need to:
- Learn to use AI tools
- Understand AI-generated code
- Focus on what AI can’t do
- Continuously learn new technologies
Programmers’ role shifts from “writing code” to “designing systems, reviewing code, solving problems.”
The Future of AI Programming#
AI programming is still developing:
Smarter
AI can understand entire codebases, not just current files.
More natural
Describe requirements in natural language, AI generates complete solutions.
More collaborative
AI participates in code review, architecture design, requirements analysis.
More autonomous
AI can independently complete simple tasks; humans only need to supervise.
Next Step: The Future is Here#
We’ve come a long way.
From knot-tying to abacus, from mechanical calculators to electronic computers, from vacuum tubes to transistors, from mainframes to personal computers, from the internet to mobile internet, from big data to AI…
Computer development is the crystallization of human wisdom.
Tomorrow, we’ll discuss the next 50 years of computing.
Today’s Key Concepts#
AI Programming Assistant: Tools using AI to assist programming, like GitHub Copilot and Cursor. AI can automatically generate code based on comments or code snippets, improving programming efficiency.
Code Completion: AI predicts the next line of code based on context. Copilot, Tabnine, and other tools provide code completion functionality.
Natural Language Programming: Describing requirements in natural language and having AI generate code. This is the direction of AI programming development.
Discussion Questions#
- AI programming assistants can generate code and improve efficiency. How do you think programmers should use AI tools?
- Some worry AI will replace programmers. What do you think is programmers’ core competitiveness?
Tomorrow’s Preview: The Future is Here—what changes will the next 50 years of computing bring?
