7 ms·
I've found that heavily commented code can be better for the LLM to read later, so it pulls in explanatory comments into context at the same time as reading cod
by Benjammer 1y ago
I've found that heavily commented code can be better for the LLM to read later, so it pulls in explanatory comments into context at the same time as reading code, similar to pulling in @docs, so maybe it's doing that on purpose?
- koakuma-chan 1y agoNo, it's just bad. I've been writing a lot of Python code past two days with Gemini 2.5 Pro Preview, and all of its code was like: ```python def whatever(): --- SECTION ONE OF THE CODE --- ... --- SECTION TWO OF THE CODE --- try: [some "dangerous" code] except Exception as e: logging.error(f"Failed to save files to {output_path}: {e}") # Decide whether to raise the error or just warn # raise IOError(f"Failed to save files to {output_path}: {e}") ``` (it adds commented out code like that all the time, "just in case") It's terrible. I'm back to Claude Code.
- brandall10 1y agoIt's certainly annoying, but you can try following up with "can you please remove superfluous comments? In particular, if a comment doesn't add anything to the understanding of the code, it doesn't deserve to be there".
- diggan 1y agoI'm having the same issue, and no matter what I prompt (even stuff like "Don't add any comments at all to anything, at any time") it still tries to add these typical junior-dev comments where it's just re-iterating what the code on the next line does.
- tough 1y agoyou can have a script that drops them all
- shawabawa3 1y agoYou don't need a follow up Just end your prompt with "no code comments"
- brandall10 1y agoI prefer not to do that as comments are helpful to guide the LLM, and esp. show past decisions so it doesn't redo things, at least in the scope of a feature. For me this tends to be more of a final refactoring step to tidy them up.
- NeutralForest 1y agoI'm seeing it trying to catch blind exceptions in Python all the time. I see it in my colleagues code all the time, it's driving me nuts.
- jerkstate 1y agoThere are a bunch of stupid behaviors of LLM coding that will be fixed by more awareness pretty soon. Imagine putting the docs and code for all of your libraries into the context window so it can understand what exceptions might be thrown!
- maccard 1y agoCopilot and the likes have been around for 4 years, and we’ve been hearing this all along. I’m bullish on LLM assistants (not vibe coding) but I’d love to see some of these things actually start to happen.
- kenjackson 1y agoI feel like it has gotten better over time, but I don't have any metrics to confirm this. And it may also depend on what type of you language/libraries that you use.
- maccard 1y agoI feel like there was a huge jump when cursor et al appeared, and things have been “changing” since then rather than improving.
- NeutralForest 1y agoIt just feels to me like trying to derive correct behavior without a proper spec so I don't see how it'll get that much better. Maybe we'll collectively remove the pathological code but otherwise I'm not seeing it.
- tclancy 1y agoWell, at least now we know who to blame for the training data :)
- deleted 1y ago[deleted]
- breppp 1y agoI always thought these were there to ground the LLM on the task and produce better code, an artifact of the fact that this will autocomplete better based on past tokens. Similarly always thought this is why ChatGPT always starts every reply with repeating exactly what you asked again
- rst 1y agoComments describing the organization and intent, perhaps. Comments just saying what a "require ..." line requires, not so much. (I find it will frequently put notes on the change it is making in comments, contrasting it with the previous state of the code; these aren't helpful at all to anyone doing further work on the result, and I wound up trimming a lot of them off by hand.)