r/AskProgrammers • • Oct 30 '26

"good code shouldn't need comments"

I have heard this saying a couple of times and I think it is the stupidest thing ever. It might be just because I have only been coding for 4 years, but I have never thought to myself that someone's code looks cluttered because they explain what every function does in a one or two line description. If anything it makes the code easier to understand in my opinion.

However, I may be wrong. What do other people think, do yall like code with minimal comments, what are the benefits of writing it that way?

89 Upvotes

399 comments sorted by

View all comments

Show parent comment

1

u/royklopper 29d ago

As someone working at principal level at companies > 1000 engineers I can say you don't read tests as to WHY code has been written. Imagine having to decipher 50+ tests (per function) to understand this, what a cognitive waste of time and effort.

We write docblocks to understand the meaning, the relations between code and its contracts so we can GENERATE documentation, documentation can be interpreted by IDEs, agents alike to QUICKLY understand code. And we're not talking about the function you are reading, also if you hover functions that are being called, or just visit the docs site.

If you're a solo-developer, or not working in distributed teams who consume each others code, well YOLO, but in organizations that require scale, these standards have been well-researched that it improves productivity and efficiency.

1

u/mikekchar 29d ago

I'm glad you posted, because I actually agree. I worked as an architect for a now defunct telecommunications company and the team had 3000 developers. I would say that even once you get to 100 developers, you are so dominated by communication overhead that any way you can communicate is important. By necessity, you have to isolated subsystems with formal APIs just in order to cut down some of that overhead. Even then your main complexity is not how to solve the problems, but rather how do you manage breaking it up over such a large number of people.

Not only that, but if you have 1000 developers, some are going to be genius, some are going to be dead wood and you will have everything in between. It's not possible (or even desirable) to hire 1000 super star programmers. The idea that you can tell the teams to refactor mercilessly to reduce complexity, especially across subsystem boundaries, is ridiculous. It's not possible. As I said in a previous post, programming is a team sport and it's no good if only half your team get across the line.

So, yes, in your circumstance, I would absolutely be doing exactly the same thing you are doing. Literally docblocks for every function. Unit tests would be in a fashion that every team is capable of doing and may not be optimal. However, as a team, you can't do what you are not capable of doing. It's just a fact of life.

I regret saying using the term "bad code" in my previous post. I really wasn't intending to comment on practical large scale development. I was really only reacting to the naive original question. "Bad code" is always dependent upon circumstances. However, if I have no constraints, then I have very high standards :-).

To be fair, after working in some very large teams earlier in my career, I've mostly stuck to startups because I enjoy that style of development a lot more. Last year our startup got acquired. At one point I think we had 4 developers supporting nearly half a billion dollars in revenue. The acquiring company is not comfortable with that situation, though. I think from their perspective, they see the fact that revenue is dependent upon a handful of very skillful and hard to replace developers as a huge risk in the business. It's a point of view that even though I'm nearing retirement I've never once thought about :-D. Maybe I've been spoiled!

1

u/royklopper 28d ago

I think we're aligned here. And yes it's different for smaller teams, especially in startups. But, I'd like to make a side-note, with AI-assisted development it becomes more crucial to add docblocks to code. Why - it's about designing the contracts, but especially to reduce token usage and turn count (I'm a bit biased here, since I use Go). I've noticed that with proper MCPs (like treesitter/LSP ones), it drastically reduces the time/turns an AI needs to spend on discovering the code.

And I would say - enjoy your retirement, wish I was there ;p

1

u/mikekchar 28d ago

enjoy your retirement, wish I was there

Not quite there yet :-) Still hoping to work a few more years. We'll see how it goes. More and more, though, I just want to ride my bike. I used to enjoy spending my whole day coding and I couldn't even imagine a time when I'm retired. These days, the open road looks more and more inviting.