I want very little comments in code. Functions should tell me what they do. And tbat's about all I really want.
Then if something is truely odd, then yes tell me what is going on in a comment. But in general there probably should not be comment in a function body.
But you don’t seem to realize. Is that a three in the morning when an ops guy is woken up to fix someone else’s code. They don’t wanna have to sit there for two hours reading through it to figure out why a function does something. At the very least being able to grep through code quickly to find things that otherwise can’t be grepped from raw code. The comments aren’t for you. They are for other people having to maintain your code in different environments.
Why would you read code comments to figure out what the code is doing when you can read the code? Also, you have to read the code anyway to make sure it’s actually doing what the comments say it’s doing, so what is the benefit?
If the code is structured and written well, it’s very easy to understand what it’s doing at a quick glance without any comments at all. It is way quicker to do that then to do it and also balance that with what the comment claimed it does.
Comments are notorious for going out of context quickly and being just flat wrong a lot of the time. There are frameworks developed just to manage this one aspect alone.
I view comments as a liability, because I’ve seen engineers get tripped up time and time again when the comments diverge from the code. If you’re relying on comments at 3am to fix an issue rather than reading the code, I really don’t know what to tell you.
Better than being punched in the nuts when the ops guy reads an incorrect code comment and takes a catastrophic action because the code diverged from the comments and what the comment told him to do was actually the wrong thing to do.
And on what planet is an ops guy actually not verifying the comments against the code anyway? Your only argument is that the ops guy wants to be able to ignore the code and just trust comments, which anyone who has programmed in a production environment knows is a terrible fucking idea.
It’s fairly clear I’m talking to a larper here so I will just leave it at this.
Even claude needs context. Whether its a human or an LLM looking at a piece of code, the only way either will understand why you took a weird route is if you add context to it through a comment. There are genuinly times when the environment calls for some weird workaround, and an LLM that is trained on 'general best practices' will not understand why you did that and just change it to a broken version that might have already been used in the past and failed.
I've worked on systems worth high tens of millions USD with teams across three continents. You have no idea what you are taking about. You don't just add comments for no reason, as developers we can read code, we aren't stupid. You write comments to explain very specific pieces of functionality or where it differs from convention or standards
If you can't read code, you're not a programmer and you're going to do more than good changing anything.
You must be a manager of some kind because you've clearly not touched code for 30 years
Lolol - worked on systems — but docs and code comments are a waste of time and not required at all by all major corporations across multiple continents 🤣 omg too funny
Of course we have documentation. We weren't talking about documentation, we were talking about code comments. If you can't even read one single Reddit comment, how would anyone trust you to read comments in code either
Perfect illustration of why you have to actually read
1
u/esaule 26d ago
I want very little comments in code. Functions should tell me what they do. And tbat's about all I really want.
Then if something is truely odd, then yes tell me what is going on in a comment. But in general there probably should not be comment in a function body.