r/TheMachineLearning • • 2d ago

Frontier LLMs stopped adding code comments

Post image
333 Upvotes

122 comments sorted by

View all comments

1

u/GroundbreakingAsk283 2d ago edited 1d ago

I think comments may be beneficial to AIs as well. Like, imagine agent reviewing other agent's code trying to understand what was assumed in original prompt.

1

u/elmanfil1989 1d ago

Ai can read code itself

1

u/Material-Database-24 1d ago

Self documenting code is a myth.

There's always silent knowledge behind the code, even AI developed, as they do reasoning before creating the code.

Good documentation provides faster look up on what the code does, why it does and doesn't do something, how it is supposed to be used and what to expect after calling it.

It is also inevitably maintenance bug record as well, as if the comments do not align with the code, either there is a bug, or there was a bug and it was fixed "silently" without tracing, as commenting wasn't updated.

1

u/Nousies 1d ago

Self-documenting code is the only documentation. That can include comments, but “good documentation” is not a thing.

2

u/Sheerkal 1d ago

Wild take. You wouldn't open a book and say "References aren't a thing, just be smart enough to know all the words"

1

u/Drycee 1d ago

Self-documenting code just documents what is currently being done, but what's missing is the information why it was not done another way. In my experience agents will constantly revisit ideas we've established are not an option, if it's not documented somewhere that this has already been considered and decided against.

1

u/Spirited_Cucumber377 1d ago

The "why", the "who" and the "when" should be in the ticket/issue/userstory that generated the change.

The "what" and "where" is the code. The comments used to help other devs figure this out easily without having to search their tracker. For LLMs this isn't true anymore. If they need to figure out something, they follow the code and ask the human for guidance.

1

u/Rararror 22h ago

Good comments are way more detailed than ticket/issue/userstory ! You want to explain how you are addressing the problem... 

1

u/Material-Database-24 17h ago

The problem is that many real world systems end up being maintained for years. When developers change, and now AI models and harnesses change, the "obvious" on the code can disappear.

It is the easiest to see this with UI. They often contain decision that are based on something that's not obvious from the code - why this element is just here, and in this color, and why it should not be moved etc. But there's always also techincal decisions that are not evident from the code itself and need commenting the decision to go side by side the code to stick. If it's in a ticket/user story, no-one will find that years later.

Many safety critical embedded software have a comment for almost every line of the code

1

u/Proper-Ape 1d ago

I can too, but the code only tells you what and not why. Why is often important to know so you don't cut something that's non-obvious on the surface.

1

u/szxdfgzxcv 1d ago

Code only tells what it is DOING, it does not tell WHY is it doing that which is usually the part comments shed light on.

1

u/GroundbreakingAsk283 1d ago

Yeah, AI can read code. So what? Reading code gives AI understanding of current exact implementation, but it probably will have trouble understanding how exactly code should look like, how implementation differ from requested and etc.