LLM Coding Practice: From Code Generation to Complex Engineering Repair

    Large language models are moving beyond one-shot code generation toward assistants that can understand project structure, debug across multiple rounds, read runtime logs, and keep revising a project. This article explains why first-pass output is a weak measure of coding ability, how constrained firmware environments expose real engineering skill, and how structured review, logs, and a human–model loop turn incomplete projects into runnable, verifiable software.

    In recent years, large language models have moved beyond “generate a snippet from a description.” They are increasingly used as coding assistants that can understand project structure, debug across multiple rounds, analyze runtime logs, and keep revising a codebase. The capability that actually matters is not how many lines appear in a single response. It is whether the model can take an incomplete, defective project with a complicated build environment and move it, step by step, toward a state that runs, can be verified, and can be maintained.

    A recent practice illustrates the point. Developers asked an intelligent coding assistant to build small graphics games in a firmware environment. One task was a Breakout-style game; the other was a Tetris-style game. The first reached written code, a successful build, and a first launch in a relatively short time. The second left several source files and a fairly clear module split, but ran into a series of problems in the build environment, runtime logic, and graphics output, and never produced a directly runnable result.

    That outcome should not be read as “one model is simply stronger.” The two tasks differed in complexity, initial code quality, environmental dependencies, and debugging path. A more reasonable conclusion is that real effectiveness depends not only on the model, but also on how the task is decomposed, how good the feedback is, what the runtime environment allows, and how the human–model workflow is organized.

    1. Do not judge a model only by the first generation

    Traditional code-generation tests usually ask whether the code is complete, whether it compiles, and whether it implements the basic feature. In real development, those checks are not enough.

    A project typically passes through these stages from requirement to delivery:

    1. Understanding the requirement
    2. Designing the project structure
    3. Implementing the code
    4. Compiling and linking
    5. Verifying at runtime
    6. Locating failures
    7. Handling compatibility
    8. Refactoring and optimization
    9. Adding documentation and planning later maintenance

    If a model can only produce plausible code in the first stage and cannot handle compile errors, crashes, or environmental differences, it is still a snippet generator, not a complete development assistant.

    This is especially true in firmware, embedded, or low-level graphics environments. Many failures are not syntax errors. They come from object lifetime, memory validity, how a protocol is obtained, call order, and hardware-interface constraints. Code can look structurally complete and still fail on the first run. Evaluation should focus on whether the model can revise its approach from real feedback, not on whether the first draft looks elegant.

    2. Constrained environments reveal engineering ability

    Ordinary application development usually has mature standard libraries, debuggers, and runtimes. Firmware programs face tighter limits, for example:

    • Limited system services
    • Graphics output that must be obtained through a specific protocol
    • Input devices that are read differently from a desktop system
    • Memory and pointer lifetimes that fail more easily
    • Build, link, and startup flows that depend heavily on configuration
    • Error messages that are often not intuitive

    In that setting, the model has to understand both business logic and the underlying runtime. Even a simple graphics game includes at least:

    • A startup entry
    • Graphics initialization
    • Framebuffer management
    • Keyboard input
    • The game loop
    • Collision
    • Score and state management
    • Screen refresh
    • Error handling and exit logic

    If the model only follows the game rules and ignores the runtime, it can produce a program that is logically correct and practically unable to start. If it first identifies low-level dependencies and then verifies graphics output, input devices, and the main loop in stages, it has a better chance of delivering a project that actually runs.

    3. Start with code review instead of a full rewrite

    When code was produced by another program and does not run, asking the model to “rewrite everything” is usually not the best move. A safer approach is a systematic review first.

    A useful order is:

    1. Check the project entry

    Confirm that the entry function exists, that initialization order is reasonable, and that startup arguments, system tables, and runtime environment information are handled correctly. Firmware programs especially need a clear entry return path and a defined path for abnormal exit.

    2. Check module dependencies

    Trace calls between source files and confirm that headers, globals, structures, and function declarations agree. More modules do not mean a better design. What matters is whether modules hide implicit dependencies or duplicate state.

    3. Check graphics resources

    Confirm that the graphics protocol was obtained, that a display mode is available, that the framebuffer address is valid, and that screen width, height, and pixel format match the drawing logic.

    4. Check input handling

    Do not stop at whether an input call exists. Confirm that the device is available, that key state does not fire repeatedly, and that input polling does not block the main loop.

    5. Check the main loop

    A game loop usually has to handle timing, input, state updates, and rendering. An infinite wait, an erroneous exit, or an unstable refresh rate can show up as a hang, a crash, or a screen that never updates.

    This way, the model first builds a map of the problems and then checks items against real runs. That is usually faster than a blind rewrite, and it is more likely to keep the useful parts of the original code.

    4. Runtime logs are the key input for debugging

    When a program exits as soon as it starts, telling the model only that “it does not run” is usually not enough. Useful debugging needs structured feedback, at least:

    • Which stage execution reached
    • The last successful call
    • Whether an abnormal state appeared
    • Whether graphics output was initialized
    • Whether an input device was detected
    • Whether anything ever appeared on screen
    • Key lines from the serial port or debug output
    • The concrete difference before and after a change

    In practice, the model can be asked to add stage logs on critical paths, for example:

    1. [BOOT] entry reached
    2. [VIDEO] protocol found
    3. [VIDEO] mode configured
    4. [INPUT] keyboard initialized
    5. [LOOP] game loop started
    6. [RENDER] first frame completed

    The value of these logs is that “the program does not run” becomes “the program failed at a specific stage.” Once the failure point is accurate, the model can reason about call order, pointer state, and return values instead of guessing from experience.

    5. A typical low-level issue: pointer lifetime and protocol state

    A common problem in firmware graphics work looks like this: the program queries an interface, receives a structure or an information pointer, then calls a function that changes the display mode, and later keeps using the pointer it saved earlier.

    That sequence looks reasonable in application logic, but the underlying interface may reallocate or update the related memory after the mode switch. The old pointer may already be invalid, and further access causes a fault. A safer sequence is:

    1. Query the current mode first
    2. Switch the display mode
    3. After a successful switch, fetch display information again
    4. Check the framebuffer address, resolution, and pixel format
    5. Only then enter the drawing path

    This class of bug is hard to confirm by static reading alone. It has to be judged from runtime logs and the meaning of the interface. Whether a model spontaneously considers that an object’s lifetime can change across a call is an important measure of low-level debugging ability.

    Another common failure is a wrong protocol identifier. Low-level interfaces usually require an exact match. An identifier with a similar name but a different meaning can make the query fail. When the graphics UI shows nothing at all, do not inspect only the draw function. Confirm, in order:

    • Whether the protocol query succeeded
    • Whether the returned object is null
    • Whether the display mode switch succeeded
    • Whether the framebuffer is writable
    • Whether the pixel format is interpreted correctly
    • Whether screen coordinates stay inside bounds

    6. Strengths and limits of coding assistants

    This kind of practice shows several clear strengths.

    First, these assistants are good at standing up a project skeleton quickly. For repetitive work such as a game loop, module splits, state machines, and basic data structures, a model can cut the cost of getting started.

    Second, they are useful for cross-file analysis. With several modules, a model can inspect the relationship among entry, rendering, input, and logic at the same time, and surface issues that a manual review is likely to miss.

    Third, they can keep running a modify–build–run–feedback loop. When the feedback is specific enough, they often fix a batch of local problems quickly.

    They also have clear limits. A model may generate code that looks reasonable but violates environmental constraints. It may misread an interface. It may remove a reported error by introducing a new hidden problem. It may also declare the task finished without a real run.

    Model output therefore does not replace testing. Developers still need the build environment, log collection, interface documentation, and basic debugging methods. More precisely, the model reduces the cost of analysis and modification. It does not remove engineering verification.

    7. How to compare models more fairly

    To compare different models or different coding setups, use one test standard:

    • The same task description
    • The same initial project
    • The same build environment
    • The same allowed tools and runtime permissions
    • Time to the first runnable result
    • Number of compile errors
    • Number of runtime failures
    • Completion of core features
    • Readability and maintainability of the code
    • Number of human interventions

    It also helps to split tasks into three levels:

    Basic level

    Check whether the model can finish a single module, such as drawing graphics, reading input, or implementing simple collision detection.

    Engineering level

    Check whether it can organize multiple modules, handle build configuration, and compile and run a complete program.

    Repair level

    Provide a project with real defects and see whether the model can locate problems from logs, change the code, and verify the fix.

    The third level is closest to real development, and it is the clearest way to separate “can generate code” from “can solve the problem.”

    8. Developers should close the human–model loop

    A more stable way of working is not to hand the whole project to the model at once. It is to keep an explicit loop:

    1. Describe the goal and the constraints first
    2. Ask the model for a plan, and do not change all of the code immediately
    3. Implement one module at a time
    4. Build after every change
    5. Start the program and collect logs
    6. Give the model the full error feedback
    7. Ask it to state the root cause and the scope of the change
    8. Let the developer confirm before expanding further
    9. Refactor, clean up, and complete documentation at the end

    That process keeps errors from stacking, and it keeps the developer in control of the project state.

    Overall, the value of the current generation of large language models on complex coding tasks is no longer limited to sample code. It extends into code review, fault location, engineering repair, and iterative improvement. At the same time, model ability has to be checked in a real environment. Surface quality of the code is not enough. For developers, the useful question is not who won a single task. It is whether the model keeps converging under clear feedback, whether it can explain why it changed the code, and whether it can take a project that only looks like an engineering effort and actually bring it to a stable, runnable state.