DEV Community

Cover image for Real Programmers Don’t Comment Code. The code comment itself
High Octane
High Octane

Posted on

Real Programmers Don’t Comment Code. The code comment itself

Ah, commenting code—the most debated ritual of programming. Some say it’s essential for clarity, others call it overkill. But let’s be honest: we’ve all seen “comments” that explain absolutely nothing or, worse, just repeat the code’s logic in plain text. So, let’s dive into the world of uncommented, “self-explanatory” code and the beauty (and chaos) of going comment-free. Why waste time writing comments when you can let your code speak for itself? Here’s a case for the brave souls who live on the edge, crafting uncommented code and living to tell the tale.


1. The Myth of Self-Documenting Code

Self-documenting code is the ultimate dream: a codebase so well-structured, with variables so perfectly named, that it needs no comments at all. Just look at it! This is the code equivalent of a minimalist design, where every function name, variable, and method serves a precise purpose, and comments would only ruin the aesthetic.

Of course, this is more a myth than a reality. But the idea is sound: why not write code so clear that it doesn’t need an explanatory essay? If calculateTaxForIncomeBracket or fetchUserProfileData are written right, they should be intuitive. Commenting, then, might be more about lazy practices than necessity. Pro tip: Use clear names and stay consistent, and you’ll be the proud creator of a “self-documenting” masterpiece.

2. Comments Don’t Get Updated

One of the biggest issues with comments is that they age faster than a carton of milk left out in the sun. When you change your code, you have to update the comments too—or do you? Most of the time, comments get forgotten or neglected, creating a codebase full of relics from the past. They describe old logic, contradict what’s actually there, and lead developers into traps of misinformation.

Imagine working through a function only to realize halfway through that every single comment is outdated. At best, you’re annoyed; at worst, you’re misled. In a comment-free world, you’re forced to read the code itself, which is, you know… the thing that actually runs.

3. Comments Are Just Repetitive

Let’s be real: a lot of comments simply restate the code in natural language. If you’re writing int x = 10; // set x to 10, we need to talk. Comments like these take up space without adding real insight. The code itself is already clear in these cases—repeating it only adds clutter. When you strip these redundant comments away, what you’re left with is cleaner, sharper, and better-focused code.

Instead, save comments for when they’re actually needed: explaining complex or non-intuitive choices. Comments are only valuable when they offer insight that goes beyond the code itself. If your code says adjustPricingBasedOnMarketDemand(), you don’t need a comment that says “adjust pricing based on market demand.”

4. Comments Can Make Code Lazy

When developers rely on comments to explain code, it can lead to some pretty bad coding habits. Code gets messy, variables are poorly named, and suddenly, there’s a ten-line comment explaining why this one random variable is named tempData. Comments can sometimes be a band-aid for code that should have been cleaned up or rewritten instead.

In other words, comments can encourage developers to write bad code, thinking, “I’ll just explain it in a comment.” But why not just make the code clearer in the first place? If a function is so complex it needs a paragraph to explain it, maybe it’s time to break it down into smaller, more understandable parts. A comment-free approach can actually push you toward writing higher-quality, cleaner code.

5. Let Code Reviews Do the Talking

In a team setting, code reviews act as the real “comments” on your code. If a developer on your team can’t understand a section of code, they’ll flag it. This gives you real-time feedback, allowing you to clarify the code rather than slapping on comments post facto. Code reviews act as a filter to catch confusing logic, variable names, and structures before the code reaches the final product. Why rely on static comments when you can get dynamic feedback?

Plus, code reviews help the team understand the code as it’s written. Unlike comments that go stale, review feedback stays relevant to the actual code. If something’s unclear, make it clear in the code itself rather than adding comments.

6. Time is Money (and Comments Take Time)

Let’s be honest: commenting takes time. You’ve already poured hours into writing this code, and now you’re supposed to go back and comment everything? For some projects, time is limited, and that extra step might not be feasible. Every minute spent writing comments could be spent refining and optimizing the code.

In fast-paced environments, focusing on writing clean, readable code can be more valuable than spending hours adding comments. It’s about using time wisely. And anyway, future you will totally understand what calcRevenueAdj() is doing… right?

7. Your Code is Your Legacy (Make It Clean)

When you write uncommented, clean code, you’re leaving behind a legacy that doesn’t rely on crutches. It’s a badge of honor. You’ve coded something so well-constructed that any developer can read through it without needing a Rosetta Stone of comments.

While comments fade into irrelevance, your uncommented masterpiece endures. When others marvel at the clarity of your code without a single word of explanation, you’ll know you’ve achieved programming greatness.

8. The Exception: When to Actually Use Comments

Alright, let’s get real for a second—sometimes comments are necessary. There will be times when the logic is just too complex, or you’re using a workaround that’s a little unconventional. When you find yourself implementing complex math, obscure business logic, or non-obvious decisions, a well-placed comment can save someone else (or future you) hours of pain.

But remember: comments should always be a last resort, not a default. Use them sparingly, and only when they genuinely add value that the code alone cannot provide.


Conclusion

At the end of the day, coding without comments is all about embracing a philosophy of clarity and efficiency. It pushes you to write better code and avoid laziness that comments can encourage. While comments have their place, most of the time, your code itself should be clear enough to understand on its own.

So next time someone tells you to comment everything, show them your beautifully crafted, uncommented code and let it speak for itself.

Top comments (1)

Collapse
 
katafrakt profile image
Paweł Świątkowski

There is a huge false dichotomy here. There are middle grounds between "comment everything" and not having comments at all.

I used to be on that side that code should be self-documenting. But I no longer think it's true. Comments add a human touch to often otherwise intimidating stream of code and they make a great entry point to unknown codebases. Reading natural language is much faster, no matter how many years of experience in a given programming language you have - it's just more expressive.

I also especially disagree with the part about code review. When you enter a dusty old part of the codebase, do you go to Github to find all possible relevant PRs and read the discussion there? I don't. But I do read the code and would prefer to see the caveats be there, not on the external platform that may go away with time.

But of course, I don't mean by that that you need to put a comment to every line. That's ridiculous. But I'm just against treating presence of comments as the sign of a bad code. It's usually otherwise, if anything.