Coding AIs Are Better at Rewriting Whole Files Than Editing Like Humans
AI assistants that make human-like small edits may actually produce worse code.
Computer scientists wanted to know: when an AI edits code, should it behave like a careful human developer, making a series of small precise changes? Or should it simply regenerate the entire file? A new study trained a pair of AI coding models both ways and put them to the test on real Flutter/Dart app code. The result was clear: the whole-file approach produced code that passed technical checks more often and was judged better by external AI evaluators.
That matters for anyone who uses AI coding assistants or benefits from software updates. Small-edit models are cheaper and more natural, but their output often failed to compile — the coding equivalent of a sentence that doesn't parse. Whole-file rewriting, however, is more computationally heavy and may change more code than necessary, which can introduce unintended side effects.
Yet the edit-based approach isn't useless. The researchers found it excels when the needed change is small and contained, like renaming a function or handling a rare error. Those quick-fix tasks require fewer sequential edits. They call this "task locality." So the ideal future tool might decide based on the task: use precise surgical edits for a one-line bug, and rewrite the file when AI makes bigger changes.
The study is limited to Flutter/Dart and smaller open models, so we shouldn't generalize to giants like GPT-4. But it gives an early empirical signal that mimicking human workflow isn't always best for machine coders. For end users, that means the assistants appearing in your coding app may become more aggressive in regenerating code — potentially improving correctness if the underlying model is strong, but demanding more human review before hitting "merge."
- AI code tools that regenerate whole files produced code that compiles more often than ones making step-by-step human-like edits.
- The small-edit approach won only on short, contained fixes — refactoring and edge-case errors — where fewer steps were needed.
- Results suggest future AI assistants might favor wholesale rewrites, potentially improving code quality but demanding stronger guardrails.
Why It Matters
This may shape how reliable AI coding assistants are, affecting how quickly software features reach your phone.