TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Is Code Commenting Outdated?

3 pointsby yujianalmost 2 years ago
Just saw a Reddit comment saying that code commenting is an outdated practice and code should be self commenting. Personally, I like commented code, I think it&#x27;s easier to read. I wanted to get HN&#x27;s thoughts on this.<p>Link to comment - https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;SoftwareEngineering&#x2F;comments&#x2F;153y4cm&#x2F;comment&#x2F;jslnvvc&#x2F;<p>Extra commentary from me: I&#x27;ve never read the mythical man month but I&#x27;ve heard mixed reviews, is it worth a read?

6 comments

theandrewbaileyalmost 2 years ago
Depends on what is meant by &quot;commenting&quot;. If it&#x27;s redundant and repeats what a human would reasonably understand by reading the code itself, then yes, it&#x27;s bad. If a comment is there explaining why it&#x27;s being done this way (e.g., some external factor that can&#x27;t be deduced from nearby code), then no, commenting is not outdated.<p>Code is for machines. Comments are for humans. If one is redundant, drop the comments.
Rochusalmost 2 years ago
&gt; <i>saying that code commenting is an outdated practice and code should be self commenting</i><p>Commenting is in no way outdated; it&#x27;s an essential part of &quot;self-documenting code&quot;; of course the comments shall not duplicate what a sufficiently skilled developer can read directly from the code, but give information about why the code is there. It also depends on the programming language in use; C can be very cryptic at times, so comments are useful; also assembler requires a lot of comments to be human comprehensible. Higher level languages need less code comments. Even Brooks himself states in &quot;The Mythical Man Month&quot;: &quot;<i>I find myself being briefer in comments to an APL program, which will live on a disk, than on a PL&#x2F;I one that I will store as cards.</i>&quot;.
justinludwigalmost 2 years ago
Comments aren&#x27;t outdated. Obvious code doesn&#x27;t need to be commented, and code should be written to be obvious where possible.<p>But where it&#x27;s not possible to write obvious code, it should have comments explaining _why_ the code is doing what it&#x27;s doing. Usually this will include references to external sources like issue trackers and software-design documents, or at least to other parts of the code.<p>Also, really hairy bits of code (like multi-page functions etc) often need comments just to explain what the heck it does (but in that case, it should also include an explanation of _why_ it&#x27;s so hairy, and the ramifications to making changes to it).<p>_The Mythical Man-Month_ is still worth a read, although many of its insights that were super hot takes 50 years ago have been pretty much adopted into the mainstream.
ompogUealmost 2 years ago
wrt mythical man month - it&#x27;s still relevant.<p>the more quoted section is about how adding devs to a late project can often make it later due to exponential communication needed.<p>the part about the top architect is still relevant to me for the person who best has the whole-picture concept for making design decisions of a system. mmm seemed to me less implementing this, but having other engineers doing a lot of other tool and data support. the reddit comment sounded more about coding style, not file system layout or code flow or design patterns or anything &quot;architectural&quot; in my mind.
damnesianalmost 2 years ago
I can sort of see their point. A program should be clear enough logically so commenting would almost be redundant.<p>However, there are different ways of doing things within the same language- so when someone comes in later with the task of changing the code to do something else, it can be a real son of a bitch to reverse-engineer even simple scripts. So as a courtesy to other professionals in a high-pressure environment, letting others know the rationale right there in the code is a simple and very useful courtesy to your fellow humans.
ompogUealmost 2 years ago
We&#x27;re doing hand-off with another team. Enterprise level.<p>They have good docs and howtos and commit logs, but then talk through sections of code where conditions are very numerous and complex to work with. We decided recently that it would be great to have in-line comments then and there to say what it does, the why on each condition.<p>My 2 cents