LLMs don't understand my code, cuz I didn't comment

3 points by fdlinly ↗ HN
Wanted to share this small but mighty lesson with y'all. I wrote a clever code to solve a problem using a greedy approach, and had GPT and Gemini and Claude to review it. Gemini said my code is functionally correct but the logic isn't right. The other two LLMs said my code was wrong. Even though my code has correct output for all of the test cases they came up with. Ok, glad I was confident enough in myself, and went through my logic again, and started ADDING COMMENTS! Now, they finally got it and all said it's a smart approach and 100% correct.

Lesson? Always comment on your code! Not just for your future self, but also for the LLMs (and the enviornment - since we won't continue the back and forth to waste inference costs.)

4 comments

[ 4.2 ms ] story [ 13.3 ms ] thread
>Now, they finally got it and all said it's a smart approach and 100% correct

Did they "get it", or did they just say it's correct, without having a similar level of not getting it as before?

My first thought as well. I hate how more recent versions of Claude keep telling me how smart my changes are ...
Not just comments — LLMs also infer meaning from function and variable names.

They really don’t understand…

Will the LLM recognize that incorrect code is wrong if you add comments?