Can Comments Help Language Models Use Code Correctly

For a long time I’ve been deleting a lot of comments, both in my own code and in generated code. Especially the ones that feel obvious when you read the code. If a function name and a few lines of logic make the intent clear, why keep a comment that just repeats it?

Now that I use language models to read, change, debug, and reuse code, I’ve started to wonder if this habit might actually be a disadvantage. Could deleting comments make it harder for a model to understand and use the code correctly when it generates changes, looks for bugs, or plugs the code into other components?

Language models work by statistics. They generate what is most likely given the text they see. That text includes not only code, but also comments. Even a comment that looks “obvious” to a human and mostly repeats what the code says might help the model by reinforcing the intended meaning. Redundancy, which we often try to remove for human readers, can actually be useful as a signal for a model.

Think of it as saying the same thing in two different ways. The code expresses behavior. The comment can restate that behavior in natural language, and sometimes add assumptions and constraints that are not explicit in the code. When both line up, you increase the probability that the model understands how the code is supposed to be used and what must not change when it modifies it.

This can matter in several situations. When you ask a model to generate changes, comments that state assumptions and intent can help it preserve the right behavior instead of “simplifying” away something important. When you ask it to find errors, differences between what the comments say and what the code does can point to potential bugs. When you ask it to reuse a function in another component, a short comment describing expected inputs, constraints, and side effects can reduce the chance of misuse.

If this is true, it might actually be worth spending time to add comments and documentation, either manually or with help from a model. Manually written comments are more likely to capture the real intent and domain rules. Generated comments can be a quick way to bootstrap documentation, as long as you review them and remove or fix anything that is misleading or simply restates the code without adding meaning.

I don’t think the answer is to comment every line; low-value comments are still noise for both humans and models. But comments that clarify intent, constraints, and usage, even when they feel a bit redundant, might be more valuable than they used to be. In a world where language models are active users of our code, those “obvious” comments could increase the chances that the code is understood and used correctly.

Leave a comment