LLM Programming Evaluation: Comparing Capabilities and Practical Testing Methods
This article explains how to evaluate LLM programming ability across requirement understanding, code correctness, defect repair, engineering quality, and iterative interaction. It compares three model archetypes, presents a shared web data extraction task with sample Python code, and outlines scoring criteria, prompt strategies, and model-selection guidance for real development workflows.
In real development, deciding whether an LLM is “good at programming” cannot rely only on response speed, code length, or a single experience. A model’s performance can vary significantly across languages, task types, context sizes, and engineering constraints.
For developers and enterprise teams, more useful questions are: Can the model accurately understand requirements? Can it generate runnable code? Can it handle exceptions? Can it continuously fix problems based on feedback? Is the generated code maintainable? Based on these criteria, three mainstream model archetypes can be compared in a structured way.
1. How Programming Ability Should Be Measured
Programming ability can usually be broken down into five layers.
1.1 Requirement Understanding
The model first needs to accurately identify the task goal, input and output formats, business constraints, and boundary conditions. For example, “collect the top 20 trending items and save them as JSON” looks simple, but it includes at least the following requirements:
- Fetch the target page content.
- Identify the rank, title, and link fields.
- Keep only the first 20 valid records.
- Handle network request failures.
- Handle changes in page structure.
- Ensure the output file conforms to standard JSON format.
- Handle duplicate data, empty fields, and encoding issues.
If a model only generates code that can “run” but ignores timeouts, status codes, character encoding, and data validation, it is closer to a code snippet generator than a reliable programming assistant.
1.2 Code Correctness
Code correctness includes syntactic correctness, reasonable dependencies, correct API usage, and expected runtime results. For automatically generated code, common problems include:
- Introducing nonexistent or unnecessary dependencies.
- Using outdated APIs.
- Inconsistent variable naming.
- Incorrect return-value type checks.
- Inaccurate loop boundaries.
- Uncovered exception branches.
- Missing encoding settings during file writes.
Therefore, evaluation cannot stop at static reading. The code must actually run in an isolated environment, and the output must be validated with test data.
1.3 Defect Repair
Defect repair is closer to real software development than generating code from scratch. Enterprise projects often contain legacy code, implicit dependencies, complex call chains, and incomplete documentation. The model must first locate the problem and then propose a modification plan.
In public software-engineering bug-fix benchmarks, leading models often score near 80% on real defect repair tasks, but differences between models can be small and may be affected by task difficulty, context length, and test coverage. In some evaluations, Model A scored about 80.9% and Model B about 80.0%. This does not mean Model A consistently leads in every scenario, nor does it simply mean that a 0.9 percentage point difference is always better.
1.4 Engineering Quality
Engineering quality is mainly reflected in:
- Whether module division is reasonable.
- Whether functions have a single responsibility.
- Whether the code is easy to test.
- Whether necessary logging is included.
- Whether a clear error-handling strategy is used.
- Whether hardcoding exists.
- Whether there is room for extension.
- Whether the code follows team coding standards.
Even if a piece of code runs normally, it is difficult to use directly in a production project if all logic is packed into one function or if addresses, timeouts, and file paths are all hardcoded.
1.5 Interaction and Iteration
Real development is rarely completed in one pass. Developers usually continue to request changes, such as adding retries, adding a proxy, changing the output structure, adding unit tests, or adapting to asynchronous calls.
An excellent model should not only complete the first generation but also remember context, accurately understand incremental requirements, and avoid modifying unrelated code. This ability is especially important for large projects.
2. Performance Characteristics of Three Mainstream Model Archetypes
To avoid mistaking one-off results for an absolute ranking, models can be abstracted as Model A, Model B, and Model C, representing three common capability routes.
Model A: Stronger Complex Code Repair
Model A usually performs well on multi-file projects, complex logic, and real defect localization. It is better at analyzing call relationships, explaining the causes of errors, and providing relatively complete modification plans.
Its advantages mainly include:
- Better understanding of long contexts.
- Greater sensitivity to exception stack traces and test failure information.
- Greater willingness to add boundary conditions.
- Relatively complete generated code structure.
- Suitable for complex refactoring and troubleshooting.
However, Model A may also produce overly long output and make overly broad modifications. For simple tasks, overdesign can increase review costs, so users should explicitly require it to “modify only the necessary parts.”
Model B: Balanced Overall Ability
Model B maintains a good balance among code generation, explanation, and debugging. For routine scripts, API wrappers, data processing, and test code, it can usually provide a runnable first draft quickly.
Its characteristics include:
- Broad knowledge of common programming patterns.
- Fast code generation.
- Suitable for daily development assistance.
- Clear explanation process.
- Ability to make multiple rounds of revisions based on error messages.
The weakness of Model B is that it may reach conclusions too early when facing hidden defects or complex problems without sufficient test evidence. Developers should ask it to list assumptions, risks, and validation methods rather than only provide final code.
Model C: Good for Rapid Prototyping and Routine Tasks
Model C is suitable for quickly validating ideas, generating boilerplate code, and completing relatively clear tasks. For simple data conversion, file processing, and basic API calls, it can often produce results quickly.
However, in complex engineering tasks, Model C may need more explicit prompts, including directory structure, input samples, expected output, and constraints. If the requirement description is too vague, the stability of the generated result may be lower than that of the first two model types.
Therefore, Model C is better suited to prototype development, learning assistance, and low-risk automation tasks. When core business logic is involved, human review and test validation are still required.
3. Practical Design for a Web Data Extraction Task
A unified task can be used to test all three model types:
Write a program that retrieves the top 20 records from the trending list on a public information page, extracts the title and link, and saves them as a JSON file.
To ensure fairness, all three model types should receive exactly the same requirements, with a unified runtime environment, input page, and validation script.
3.1 Basic Implementation Example
The following code only demonstrates a general implementation approach and is not tied to any specific platform or website:
import jsonfrom urllib.request import Request, urlopenfrom html.parser import HTMLParserclass ItemParser(HTMLParser):def __init__(self):super().__init__()self.items = []self.current = Nonedef handle_starttag(self, tag, attrs):attrs = dict(attrs)if tag == "a" and attrs.get("data-role") == "item":self.current = {"title": "","url": attrs.get("href", "")}def handle_data(self, data):if self.current is not None:self.current["title"] += data.strip()def handle_endtag(self, tag):if tag == "a" and self.current is not None:if self.current["title"] and self.current["url"]:self.items.append(self.current)self.current = Nonedef fetch_items(page_url, output_path, limit=20):request = Request(page_url,headers={"User-Agent": "Mozilla/5.0"})with urlopen(request, timeout=10) as response:if response.status != 200:raise RuntimeError(f"request failed: {response.status}")html = response.read().decode("utf-8", errors="replace")parser = ItemParser()parser.feed(html)result = parser.items[:limit]with open(output_path, "w", encoding="utf-8") as file:json.dump(result, file, ensure_ascii=False, indent=2)return len(result)
This example illustrates several important principles:
- Set a request timeout to prevent the program from waiting indefinitely.
- Check the response status.
- Explicitly handle character encoding.
- Perform basic validation on titles and links.
- Use a parameter to control the number of records.
- Write the file in standard JSON format.
In real projects, the parsing logic also needs to be adjusted according to the page structure, and page changes, request rate limits, retry strategies, and legal and compliance requirements should be considered.
4. Evaluation Should Not Stop at “Does It Run”
A complete scoring table can include the following dimensions:
| Evaluation Dimension | Focus |
|---|---|
| Syntax correctness | Whether it passes interpreter or compiler checks |
| Runtime success rate | Whether it executes normally in the specified environment |
| Output accuracy | Whether fields, counts, and formats meet requirements |
| Exception handling | Whether network failures, empty data, and invalid responses are covered |
| Maintainability | Whether module division, naming, and comments are clear |
| Security | Whether unsafe input handling or sensitive information leakage exists |
| Change cost | Whether it is easy to extend when new requirements are added |
| Explanation quality | Whether design rationale, limitations, and validation methods are explained |
Among these, successful execution is only the minimum standard. If a program can only run in an ideal network environment and crashes immediately when one request fails, it is still not suitable for a formal workflow.
5. How to Improve Model Output Quality
5.1 Provide Clear Acceptance Criteria
Do not just say “write a scraper for me.” Instead, specify:
- Which programming language to use.
- What the input and output are.
- Which fields need to be retained.
- The maximum number of records to process.
- How failures should be handled.
- Whether logging and tests are required.
- Whether third-party dependencies are restricted.
The clearer the constraints, the more stable the model’s output will be.
5.2 Ask the Model to Analyze Before Coding
The model can be asked to first output:
- Requirement breakdown.
- Potential risks.
- Implementation plan.
- Test plan.
- Final code.
This approach helps identify omissions and allows developers to correct misunderstandings before code generation.
5.3 Use Test-Driven Interaction
First provide input samples and expected output, then ask the model to generate test cases, and finally implement the code. This reduces the risk of code that “looks reasonable but produces incorrect results.”
5.4 Control Modification Scope
For existing projects, explicitly require:
- Do not modify unrelated files.
- Preserve existing public interfaces.
- Prefer patch-style modifications.
- List changed files and reasons for changes.
- Do not introduce new dependencies without approval.
This can reduce chain effects caused by the model in complex projects.
6. Practical Advice for Model Selection
If the task involves complex defect localization, multi-file refactoring, or long-term maintenance, prioritize models with stronger context understanding and debugging capabilities.
If the task involves daily scripts, API wrappers, test generation, and code explanation, a model with balanced overall ability is usually more efficient.
If the task involves rapid prototyping, learning assistance, or simple automation, a model with fast response and a low usage barrier can meet the requirements.
The final choice should not be based on a single leaderboard or one experience. Instead, it should be validated against the team’s own codebase, technology stack, privacy requirements, and review workflow. For enterprise users, permission control, data isolation, audit logging, and human approval mechanisms should also be considered.
Conclusion
The three mainstream model archetypes each have different strengths in programming: some are good at complex problem repair, some emphasize overall stability, and some are suitable for rapid prototyping and routine tasks. A so-called “first place” only represents results under a specific dataset and test conditions and cannot replace validation in real projects.
A more reliable approach is to build an internal evaluation set covering code generation, defect repair, test completion, documentation understanding, and security review, and to use runnable results, maintenance cost, and manual review time as the final basis. Only by combining model capabilities with standardized processes can AI coding tools truly become stable and controllable development productivity.
