Code Generation
Using an AI model to write source code from a natural-language description, a partial snippet, or a test.
In plain English
Code generation is one of the most successful applications of large language models. Modern models can write, refactor, translate, and explain code across most popular languages — often well enough to replace boilerplate work entirely.
Common forms:
- Inline completion — predict the next few characters or lines (GitHub Copilot, Cursor Tab)
- Function from spec — generate a whole function from a comment or docstring
- Test-to-code — write code that passes a given test
- Translation — convert code from one language or framework to another
- Refactoring — rewrite existing code for clarity, performance, or a new API
Top models for code: Claude (Sonnet 4.x, Opus 4.x), GPT-4o/5, DeepSeek-Coder, Qwen-Coder, and open-source Llama Code derivatives. Most agentic coding tools combine a strong general model with a code-tuned model for autocomplete.
Limits: Models still produce subtly wrong code that compiles but fails edge cases — type errors, off-by-one bugs, missing null checks. Code review (human or automated) remains essential.