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

high_octane

High Octane

Posted on November 8, 2024

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.

💖 💪 🙅 🚩
high_octane
High Octane

Posted on November 8, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related