Remix.run Logo
evanmoran a day ago

I know this is highly controversial, but I now leave the comments in. My theory is that the “probability space” the LLM is writing code in can’t help but write them, so if i leave them next LLM that reads the code will start in the same space. Maybe it’s too much, but currently I just want the code to be right and I’ve let go of the exact wording of comments/variables/types to move faster.

stuaxo 21 hours ago | parent | next [-]

Similar logic, but hard disagree on keeping comments that are exactly what the following code does.

They are useful to the LLM in writing the code (which comes after).

But when it comes to an LLM reading that code later its just a waste of context.

For humans its a waste of screen space.

A comment should only explain what the following thing does if its hard to parse for some reason.

Otherwise it should add information: why something is as it is, I.e. some special case, add breadcrumbs to other bits of the code etc.

I wish these coding agents had a post step to remove any LLMish comments they added during writing, and I want linters that flag these.

lolc 13 hours ago | parent [-]

Prompting to remove redundant comments works quite well, but I dislike the extra step.

jychang a day ago | parent | prev [-]

I think the code comments straight up just help understanding, whether human or AI.

There's a piece of common knowledge that NBA basketball players can all hit over 90% on free throws, if they shot underhand (granny style). But for pride reasons, they don't throw underhand. Shaq just shot 52%, even though it'd be free points if he could easily shoot better.

I suspect there's similar things in software engineering. I've seen plenty of comments on HN about "adding code comments like a junior software engineer" or similar sentiment. Sure, there's legitimate gripes about comments (like how they can be misleading if you update the code without changing the comment, etc), but I strongly suspect they increase comprehension of code overall.

lukeschlather 12 hours ago | parent | next [-]

I can't speak to LLMs, but one of my first tasks was debugging a race condition in a piece of software. (I had no idea that it was a race condition, or even what part of the code it was in.) I spent months babysitting the service and reading the codebase. When I finally fixed the issue the source turned out to be a comment that said the opposite of what the code actually did. The code was a very convoluted one-line guard involving a ternary if / several || && statements. If the comment hadn't been there I think I would've read the code sooner and realized the issue.

Personally, I remove redundant comments AI adds specifically to demonstrate that I have reviewed the code and believe that the AI's description is accurate. In many cases AIs will even add comments that only make sense as a response to my prompt and don't make any sense in-context.

lolc 13 hours ago | parent | prev | next [-]

I like comments about intent, about the why. The generators are really bad at intent, they just write dross comments about the how. The worst part is how they're not accustomed to comments about intent and tend to drop those!

Say I wrote a specific comment why this fencepost here needs special consideration. The agent will come through and replace that reasoned comment with "Add one to index".

thenanyu 20 hours ago | parent | prev [-]

I hate this analogy. NBA players can all hit 90% of their free throws shooting overhand too. Just some of them are much worse at handling the pressure and pace change of the situation in a game context.

oblio 16 hours ago | parent [-]

The underhanded throw is mechanically just better for free throws. Much easier to put backspin, for example. It's just a shot that doesn't help anywhere else.

thenanyu 14 hours ago | parent [-]

That’s beside the point. It wouldn’t help shaq or any of those big men hit free throws. They have no problems with mechanics.

jychang 6 hours ago | parent [-]

> have no problems with mechanics.

What? Shaq shot free throws at 85% in practice. Players with good mechanics like Curry wouldn't be caught dead shooting 85% during the season, he's always 90%+ at free throws. Curry would probably shoot free throws at 99.9% in practice; there's plenty of stories of him swishing 100 3-pointers in a row in practice.

I'm not saying Shaq would shoot free throws as good as "90% in game and 99.9% in practice" if he threw free throws underhanded, but clearly Shaq had mechanics issues.